:root {
  --rot: #ff1a1a;
  --weiss: #ffffff;
  --schwarz: #111111;
  --grau: #f1f1f1;
  --linie: 2px solid var(--schwarz);
  --schatten: 4px 4px 0 var(--schwarz);
  --taskbar: 48px;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--rot);
  color: var(--schwarz);
  font: 16px/1.5 var(--sans);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

img {
  max-width: 100%;
  display: block;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

:focus-visible {
  outline: 2px dashed var(--weiss);
  outline-offset: 3px;
}

.win :focus-visible {
  outline-color: var(--schwarz);
}

/* Desktop */

.desktop {
  position: relative;
  height: calc(100% - var(--taskbar));
  overflow: hidden;
}

.icons {
  position: absolute;
  top: 16px;
  left: 16px;
  display: grid;
  gap: 10px;
  z-index: 1;
}

.icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 84px;
  padding: 8px 4px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--weiss);
  font: 600 12px/1.2 var(--sans);
  text-align: center;
  text-decoration: none;
}

.icon:hover {
  background: rgba(0, 0, 0, 0.12);
}

.icon__img {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  background: var(--weiss);
  border: var(--linie);
  border-radius: 12px;
  box-shadow: 3px 3px 0 var(--schwarz);
  font-size: 26px;
  line-height: 1;
}

.icon__img--mono {
  background: var(--schwarz);
  color: var(--weiss);
  font: 700 16px var(--mono);
}

/* Fenster */

.win {
  position: absolute;
  top: var(--y, 40px);
  left: clamp(120px, var(--x, 160px), calc(100% - min(var(--w, 420px), 100% - 136px) - 16px));
  width: min(var(--w, 420px), calc(100% - 136px));
  max-height: calc(100% - var(--y, 40px) - 16px);
  display: flex;
  flex-direction: column;
  background: var(--weiss);
  border: var(--linie);
  border-radius: 10px;
  box-shadow: var(--schatten);
  overflow: hidden;
  z-index: 2;
}

.win[hidden] {
  display: none;
}

.win__bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 6px 6px 12px;
  border-bottom: var(--linie);
  background: var(--grau);
  font: 600 13px var(--mono);
  user-select: none;
  touch-action: none;
  cursor: grab;
}

.win__bar:active {
  cursor: grabbing;
}

.win__title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.win__close {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: var(--linie);
  border-radius: 6px;
  background: var(--weiss);
  font: 700 14px/1 var(--mono);
}

.win__close:hover {
  background: var(--rot);
  color: var(--weiss);
}

.win__body {
  padding: 16px;
  overflow: auto;
}

.win__body--flush {
  padding: 0;
}

.btn {
  padding: 8px 14px;
  border: var(--linie);
  border-radius: 8px;
  background: var(--weiss);
  font-weight: 600;
  box-shadow: 2px 2px 0 var(--schwarz);
}

.btn:active {
  transform: translate(2px, 2px);
  box-shadow: none;
}

.btn--primary {
  background: var(--schwarz);
  color: var(--weiss);
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Startseite */

.fact {
  margin: 0 0 16px;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.35;
}

.meme {
  background: var(--schwarz);
}

.meme img {
  width: 100%;
  max-height: 60vh;
  object-fit: contain;
}

.meme__caption {
  margin: 0;
  padding: 8px 12px;
  border-top: var(--linie);
  font: 12px var(--mono);
  overflow-wrap: anywhere;
}

/* Dialog */

.dialog {
  --w: 360px;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 50;
  width: min(var(--w), calc(100% - 32px));
  max-height: none;
}

.dialog__text {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  margin: 0 0 16px;
}

.dialog__icon {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--rot);
  color: var(--weiss);
  font: 700 18px var(--mono);
}

/* Terminal */

.terminal {
  --w: 560px;
  --y: 80px;
  --x: 50%;
}

.terminal .win__body {
  background: var(--schwarz);
  color: #e8e8e8;
  font: 13px/1.55 var(--mono);
  min-height: 280px;
}

.term__out p {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.term__out .cmd {
  color: var(--weiss);
  font-weight: 700;
}

.term__out .ok {
  color: #7dff9a;
}

.term__out .err {
  color: #ff8080;
}

.term__out a {
  color: var(--weiss);
}

.term__form {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

.term__prompt {
  color: var(--rot);
  font-weight: 700;
}

.term__input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--weiss);
  font: inherit;
  outline: none;
  caret-color: var(--rot);
}

.term__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid #333;
}

.term__chip {
  padding: 2px 8px;
  border: 1px solid #555;
  border-radius: 4px;
  background: none;
  color: #ccc;
  font: 12px var(--mono);
}

.term__chip:hover {
  border-color: var(--weiss);
  color: var(--weiss);
}

/* Sticker */

.sticker {
  position: absolute;
  z-index: 1;
  padding: 10px 14px;
  border: var(--linie);
  background: var(--weiss);
  font: 800 18px/1 var(--sans);
  text-transform: uppercase;
  letter-spacing: -0.02em;
  transform: rotate(var(--r, -6deg));
  user-select: none;
  touch-action: none;
  cursor: grab;
}

.sticker::before {
  content: "";
  position: absolute;
  top: -10px;
  left: 50%;
  width: 46px;
  height: 16px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(0, 0, 0, 0.12);
  transform: translateX(-50%) rotate(3deg);
}

.sticker--353 {
  right: 48px;
  bottom: 60px;
  border-radius: 50%;
  width: 92px;
  height: 92px;
  display: grid;
  place-items: center;
  font-size: 30px;
  --r: 10deg;
}

.sticker--hoelle {
  right: 180px;
  bottom: 36px;
  color: var(--rot);
  font-family: "Marker Felt", "Comic Sans MS", var(--sans);
  font-size: 15px;
  line-height: 1.05;
  text-align: center;
}

.sticker--rakete {
  right: 330px;
  bottom: 40px;
  padding: 0;
  border: 0;
  background: none;
  --r: 18deg;
}

.sticker--rakete::before {
  top: 2px;
}

.sticker--rakete svg {
  display: block;
  overflow: visible;
  stroke: var(--schwarz);
  stroke-width: 2.5;
  stroke-linejoin: round;
}

.rakete__rumpf {
  fill: var(--weiss);
}

.rakete__spitze,
.rakete__flosse {
  fill: var(--schwarz);
}

.rakete__flamme {
  fill: var(--weiss);
}

.sticker--rakete text {
  fill: var(--rot);
  stroke: none;
  font: 800 14px/1 var(--sans);
  text-transform: none;
  letter-spacing: -0.02em;
  text-anchor: middle;
  dominant-baseline: central;
}

/* Taskleiste */

.taskbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  height: var(--taskbar);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
  background: var(--schwarz);
  color: var(--weiss);
}

.taskbar__apps {
  display: flex;
  align-items: center;
  gap: 4px;
}

.tb {
  position: relative;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--weiss);
  font-size: 22px;
  line-height: 1;
  text-decoration: none;
  transition: background 0.12s;
}

.tb:hover,
.tb[aria-expanded="true"] {
  background: rgba(255, 255, 255, 0.12);
}

.tb:active > * {
  transform: scale(0.88);
}

.tb::after {
  content: "";
  position: absolute;
  bottom: 2px;
  left: 50%;
  width: 0;
  height: 3px;
  border-radius: 2px;
  background: var(--rot);
  transform: translateX(-50%);
  transition: width 0.15s;
}

.tb[aria-current="page"]::after,
.tb.is-running::after {
  width: 16px;
}

.tb__mono {
  font: 700 14px var(--mono);
}

.tb__logo {
  display: grid;
  grid-template-columns: 9px 9px;
  gap: 2px;
}

.tb__logo i {
  width: 9px;
  height: 9px;
  border-radius: 2px;
  background: var(--rot);
}

.tb__logo i:nth-child(2),
.tb__logo i:nth-child(3) {
  background: var(--weiss);
}

.taskbar__clock {
  position: absolute;
  right: 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font: 12px/1.3 var(--sans);
}

.startmenu {
  position: fixed;
  left: 50%;
  bottom: calc(var(--taskbar) + 10px);
  z-index: 45;
  width: min(400px, calc(100% - 24px));
  background: var(--weiss);
  border: var(--linie);
  border-radius: 12px;
  box-shadow: var(--schatten);
  transform: translateX(-50%);
  overflow: hidden;
  animation: startmenu-in 0.18s ease-out;
}

@keyframes startmenu-in {
  from {
    opacity: 0;
    transform: translate(-50%, 16px);
  }
}

.startmenu[hidden] {
  display: none;
}

.startmenu__title {
  margin: 0;
  padding: 16px 20px 8px;
  font: 700 13px var(--sans);
}

.startmenu__grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 0 12px 16px;
}

.sm-app {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 4px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--schwarz);
  font-size: 12px;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
}

.sm-app:hover {
  background: var(--grau);
}

.sm-app__icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  font-size: 24px;
  line-height: 1;
}

.sm-app__icon--mono {
  border-radius: 8px;
  background: var(--schwarz);
  color: var(--weiss);
  font: 700 13px var(--mono);
}

.startmenu__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-top: var(--linie);
  background: var(--grau);
}

.startmenu__user {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 600;
}

.startmenu__avatar {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--rot);
  color: var(--weiss);
  font: 800 13px var(--sans);
}

.startmenu__power {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: none;
}

.startmenu__power:hover {
  background: var(--rot);
  color: var(--weiss);
}

.startmenu__power svg {
  width: 18px;
  height: 18px;
}

.confetti {
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
}

/* Handy: Homescreen statt Fenster */

@media (max-width: 720px) {
  .desktop {
    overflow-y: auto;
    padding: 16px 16px 24px;
  }

  .icons {
    position: static;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    margin-bottom: 8px;
  }

  .icon {
    width: auto;
  }

  .win {
    position: static;
    width: 100%;
    max-height: none;
    margin-top: 16px;
  }

  .win__bar {
    cursor: default;
  }

  .win--app,
  .terminal {
    position: fixed;
    inset: 0 0 var(--taskbar) 0;
    width: auto;
    margin: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    z-index: 30;
  }

  .win--app .win__body,
  .terminal .win__body {
    flex: 1;
  }

  .dialog {
    position: fixed;
    width: calc(100% - 32px);
    margin: 0;
  }

  .sticker {
    display: none;
  }

  .taskbar {
    justify-content: flex-start;
  }

  .tb {
    width: 38px;
  }

  .taskbar__clock span + span {
    display: none;
  }
}

/* Lockscreen (nur Handy) */

.lock {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  background: var(--rot);
  color: var(--weiss);
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  transition: opacity 0.35s ease 0.15s;
  touch-action: none;
}

.lock__glass {
  background:
    linear-gradient(rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.05) 50%, transparent 50%),
    rgba(0, 0, 0, 0.62);
  transition: transform 0.4s ease-in;
}

.lock__status {
  display: flex;
  justify-content: space-between;
  padding: 4px 10px;
  background: rgba(0, 0, 0, 0.85);
  font-size: 12px;
  font-weight: 700;
}

.lock__top {
  padding: 10px 16px 14px;
  text-align: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.lock__time {
  margin: 0;
  font-size: 72px;
  font-weight: 200;
  line-height: 1;
  letter-spacing: -0.02em;
}

.lock__date {
  margin: 6px 0 0;
  font-size: 16px;
}

.lock__wall {
  flex: 1;
  display: grid;
  place-items: center;
}

.lock__wall span {
  display: grid;
  place-items: center;
  width: 128px;
  height: 128px;
  border: var(--linie);
  border-radius: 50%;
  background: var(--weiss);
  color: var(--schwarz);
  font: 800 42px var(--sans);
  transform: rotate(10deg);
  box-shadow: var(--schatten);
}

.lock__bottom {
  padding: 22px 20px calc(22px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(255, 255, 255, 0.15);
}

.slider {
  position: relative;
  max-width: 360px;
  margin: 0 auto;
  height: 64px;
  padding: 5px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 14px;
  background: linear-gradient(#0c0c0c, #262626);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.8);
}

.slider__text {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding-left: 60px;
  font-size: 22px;
  color: transparent;
  background: linear-gradient(100deg, #6f6f6f 40%, #ffffff 50%, #6f6f6f 60%) 0 0 / 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  animation: lock-shimmer 2.4s linear infinite;
  pointer-events: none;
}

@keyframes lock-shimmer {
  from {
    background-position: 150% 0;
  }
  to {
    background-position: -50% 0;
  }
}

.slider__knob {
  position: relative;
  width: 64px;
  height: 52px;
  padding: 0;
  border: 1px solid #888;
  border-radius: 10px;
  background: linear-gradient(#ffffff, #d9d9d9 50%, #c4c4c4 50%, #e6e6e6);
  color: #7a7a7a;
  font-size: 30px;
  line-height: 1;
  touch-action: none;
  cursor: grab;
}

.slider__knob.is-snapping {
  transition: transform 0.25s ease-out;
}

.lock.is-unlocking {
  opacity: 0;
  pointer-events: none;
}

.lock.is-unlocking .lock__head {
  transform: translateY(-100%);
}

.lock.is-unlocking .lock__bottom {
  transform: translateY(100%);
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}
