:root {
  --bg: #b9c9d8;
  --panel: #eff5fb;
  --panel-2: #d9e6f2;
  --panel-3: #c3d3e4;
  --line: #243746;
  --text: #13212c;
  --muted: #4a6170;
  --shadow: rgba(14, 30, 44, 0.24);
  --screen: #8fb1cf;
  --paper: #ffffff;
  --office-blue: #6f98bf;
  --office-dark: #1b2c3b;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: "Courier New", "Lucida Console", monospace;
  color: var(--text);
  background: linear-gradient(180deg, #d5e1eb 0%, #9bb1c6 100%);
  image-rendering: pixelated;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(
      180deg,
      rgba(36, 55, 70, 0.03) 0,
      rgba(36, 55, 70, 0.03) 2px,
      transparent 2px,
      transparent 4px
    ),
    repeating-linear-gradient(
      90deg,
      rgba(255, 255, 255, 0.07) 0,
      rgba(255, 255, 255, 0.07) 2px,
      transparent 2px,
      transparent 6px
    );
  opacity: 0.7;
}

.app-shell {
  min-height: 100dvh;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 12px;
  width: min(100%, 760px);
  margin: 0 auto;
  padding:
    calc(12px + var(--safe-top))
    calc(16px + var(--safe-right))
    calc(16px + var(--safe-bottom))
    calc(16px + var(--safe-left));
}

.topbar,
.feed-modal,
.event-card,
.choice-button,
.ghost-button,
.office-strip,
.icon-button {
  border: 4px solid var(--line);
  box-shadow: 8px 8px 0 var(--shadow);
}

.topbar,
.feed-modal,
.event-card {
  background: var(--panel);
}

.topbar {
  padding: 10px 10px 8px;
  overflow: hidden;
}

.topbar-row,
.feed-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand,
.dayline,
.feed-header p,
.stat-label,
.eyebrow,
.context-line {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.brand,
.dayline,
.feed-header p,
.stat-label,
.eyebrow {
  font-size: 0.8rem;
}

.dayline,
.feed-header p,
.eyebrow,
.context-line {
  color: var(--muted);
}

.stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: -18px;
  position: relative;
  z-index: 1;
}

.version-mark {
  margin: 6px 0 0;
  text-align: right;
  font-size: 0.54rem;
  line-height: 1;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(74, 97, 112, 0.8);
}

.stat-card {
  background: var(--panel-2);
  border: 3px solid var(--line);
  padding: 6px 8px;
  transition: transform 140ms steps(2), background-color 140ms steps(2);
}

.stat-card[data-flash="up"] {
  background: #bce5c8;
  transform: translateY(-2px);
}

.stat-card[data-flash="down"] {
  background: #f2c4c4;
  transform: translateY(2px);
}

.stat-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 5px;
  align-items: center;
}

.stat-label {
  font-size: 0.95rem;
  line-height: 1;
}

.stat-value {
  font-weight: 700;
  font-size: 0.88rem;
}

.bar {
  height: 10px;
  border: 3px solid var(--office-dark);
  background: #dce4eb;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  width: 50%;
  background:
    repeating-linear-gradient(
      90deg,
      currentColor 0,
      currentColor 8px,
      rgba(255, 255, 255, 0.15) 8px,
      rgba(255, 255, 255, 0.15) 12px
    );
  transition: width 260ms steps(12);
}

.card-frame {
  display: grid;
  align-items: stretch;
  min-height: 0;
}

.office-strip {
  position: relative;
  height: 78px;
  overflow: hidden;
  background: linear-gradient(180deg, #dce7f1 0 62%, #b6c7d7 62% 100%);
  margin-top: 8px;
}

.window-grid {
  position: absolute;
  left: 18px;
  top: 10px;
  width: 108px;
  height: 42px;
  background:
    linear-gradient(90deg, transparent 0 30%, var(--line) 30% 36%, transparent 36% 64%, var(--line) 64% 70%, transparent 70% 100%),
    linear-gradient(180deg, transparent 0 45%, var(--line) 45% 55%, transparent 55% 100%),
    var(--screen);
  border: 4px solid var(--line);
}

.desk,
.plant,
.monitor,
.coffee {
  position: absolute;
}

.desk {
  bottom: 10px;
  width: 74px;
  height: 12px;
  background: #5e7284;
  border: 4px solid var(--line);
}

.desk::before,
.desk::after {
  content: "";
  position: absolute;
  bottom: -20px;
  width: 8px;
  height: 20px;
  background: var(--line);
}

.desk::before {
  left: 8px;
}

.desk::after {
  right: 8px;
}

.desk-a {
  left: 154px;
}

.desk-b {
  right: 30px;
}

.monitor {
  left: 176px;
  bottom: 28px;
  width: 28px;
  height: 18px;
  background: #89b6de;
  border: 4px solid var(--line);
}

.monitor::before {
  content: "";
  position: absolute;
  left: 10px;
  bottom: -12px;
  width: 8px;
  height: 12px;
  background: var(--line);
}

.plant {
  right: 118px;
  bottom: 24px;
  width: 20px;
  height: 20px;
  background: #67aa72;
  border: 4px solid var(--line);
}

.plant::before,
.plant::after {
  content: "";
  position: absolute;
  background: #67aa72;
  border: 4px solid var(--line);
}

.plant::before {
  left: -8px;
  top: -14px;
  width: 12px;
  height: 14px;
}

.plant::after {
  right: -8px;
  top: -12px;
  width: 12px;
  height: 12px;
}

.coffee {
  right: 58px;
  bottom: 24px;
  width: 12px;
  height: 16px;
  background: #fff1cf;
  border: 4px solid var(--line);
}

.coffee::before {
  content: "";
  position: absolute;
  right: -10px;
  top: 2px;
  width: 6px;
  height: 8px;
  border: 4px solid var(--line);
  border-left: 0;
}

.event-card {
  padding: 14px;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  transition: transform 220ms ease, opacity 220ms ease;
  touch-action: pan-y;
  background:
    linear-gradient(180deg, #ffffff 0 18px, #eff5fb 18px 100%);
}

.event-card.is-compact {
  padding: 12px;
  gap: 10px;
}

.event-card.is-compact h1 {
  font-size: clamp(1.18rem, 3.9vw, 1.72rem);
}

.event-card.is-compact .event-text {
  font-size: clamp(0.88rem, 2.85vw, 0.98rem);
  line-height: 1.34;
}

.event-card.is-compact .context-line {
  min-height: 2.3em;
  font-size: 0.8rem;
  line-height: 1.28;
}

.event-card.is-tight {
  padding: 10px;
  gap: 8px;
}

.event-card.is-tight h1 {
  font-size: clamp(1.02rem, 3.35vw, 1.46rem);
}

.event-card.is-tight .event-text {
  font-size: clamp(0.8rem, 2.6vw, 0.92rem);
  line-height: 1.25;
}

.event-card.is-tight .context-line {
  min-height: 2em;
  font-size: 0.74rem;
  line-height: 1.2;
}

.swipe-hints {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: -4px;
}

.swipe-hint {
  display: inline-block;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
  opacity: 0.8;
}

.event-card.is-animating {
  transform: translateY(8px);
  opacity: 0.85;
}

.event-card.is-dragging {
  transition: none;
}

.event-card.game-over {
  background:
    linear-gradient(180deg, #fff8ea 0 24px, #ffd1d1 24px 100%);
}

.event-card.victory {
  background:
    linear-gradient(180deg, #fff8ea 0 24px, #ffe6a6 24px 100%);
}

.game-over-actions {
  display: flex;
  justify-content: flex-end;
  padding-top: 2px;
}

h1 {
  margin: 0;
  font-size: clamp(1.35rem, 4.5vw, 2.1rem);
  line-height: 1;
  text-transform: uppercase;
}

.event-text {
  margin: 0;
  font-size: clamp(0.96rem, 3.2vw, 1.06rem);
  line-height: 1.42;
}

.context-line {
  min-height: 2.7em;
  font-size: 0.86rem;
  line-height: 1.35;
}

.controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding-bottom: max(0px, var(--safe-bottom));
}

.choice-button,
.ghost-button,
.icon-button {
  appearance: none;
  padding: 16px 14px;
  font: inherit;
  color: var(--text);
  cursor: pointer;
}

.choice-button {
  min-height: clamp(74px, 14dvh, 96px);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 8px;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.3;
  transition: transform 120ms steps(2), filter 120ms steps(2);
}

.icon-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--panel-2);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.72rem;
  line-height: 1;
}

.language-toggle {
  gap: 4px;
  min-width: 56px;
  justify-content: center;
}

.flag {
  font-size: 0.92rem;
  line-height: 1;
  opacity: 0.4;
  transition: opacity 140ms steps(2), transform 140ms steps(2);
}

.language-toggle[data-language="en"] .flag-en,
.language-toggle[data-language="de"] .flag-de {
  opacity: 1;
  transform: translateY(-1px);
}

.icon-button-symbol {
  font-size: 1rem;
}

.modal-close {
  flex-shrink: 0;
}

.choice-tag {
  display: inline-block;
  font-size: 1.05rem;
  line-height: 1;
}

.choice-tag-right {
  align-self: flex-end;
}

.choice-copy {
  display: block;
  text-align: left;
}

.choice-left {
  background: #7da1c6;
}

.choice-right {
  background: #dce5ef;
}

.choice-button:active,
.ghost-button:active {
  transform: translateY(4px);
  box-shadow: 0 4px 0 var(--shadow);
}

.choice-button:disabled {
  filter: grayscale(0.35);
  cursor: not-allowed;
}

.ghost-button {
  background: var(--panel-2);
}

.game-over-actions .ghost-button {
  min-width: 180px;
  background: #ffffff;
}

.restart-button {
  min-width: auto;
  width: 44px;
  height: 44px;
  padding: 0;
  justify-content: center;
  background: #ffffff;
  flex-shrink: 0;
}

.restart-button .icon-button-symbol {
  font-size: 1.2rem;
}

.hidden {
  display: none;
}

.modal-shell.hidden {
  display: none;
}

.modal-shell {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding:
    calc(18px + var(--safe-top))
    calc(18px + var(--safe-right))
    calc(18px + var(--safe-bottom))
    calc(18px + var(--safe-left));
  background: rgba(19, 33, 44, 0.48);
}

.feed-modal {
  width: min(100%, 620px);
  max-height: min(72vh, 620px);
  padding: 14px;
  display: flex;
  flex-direction: column;
}

#history {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  display: grid;
  gap: 10px;
  max-height: 100%;
  overflow: auto;
}

.history-item {
  border-left: 4px solid var(--line);
  padding-left: 10px;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.4;
  background: rgba(255, 255, 255, 0.35);
}

.history-item strong {
  color: var(--text);
}

@media (max-width: 560px) {
  .app-shell {
    gap: 10px;
  }

  .stats {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
    margin-top: 6px;
  }

  .topbar {
    padding: 7px;
  }

  .topbar-row {
    gap: 8px;
    align-items: flex-start;
  }

  .brand,
  .dayline,
  .feed-header p,
  .eyebrow {
    font-size: 0.7rem;
  }

  .topbar-actions {
    gap: 6px;
  }

  .icon-button {
    padding: 5px 8px;
    font-size: 0.64rem;
  }

  .icon-button-label {
    display: none;
  }

  .stat-card {
    padding: 4px 4px 3px;
  }

  .version-mark {
    margin-top: 4px;
    font-size: 0.48rem;
  }

  .stat-row {
    justify-content: center;
    margin-bottom: 3px;
    gap: 0;
  }

  .stat-label {
    font-size: 0.82rem;
  }

  .stat-value {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .bar {
    height: 6px;
    border-width: 2px;
  }

  .controls {
    grid-template-columns: 1fr;
  }

  .office-strip {
    height: 62px;
    margin-top: 6px;
  }

  .desk-a {
    left: 118px;
  }

  .desk-b {
    right: 12px;
  }

  .monitor {
    left: 136px;
  }

  .plant {
    right: 82px;
  }

  .event-card {
    padding: 12px;
  }

  .swipe-hint,
  .choice-tag {
    font-size: 0.95rem;
  }

  .choice-button {
    min-height: clamp(64px, 12dvh, 82px);
    padding: 12px 12px 11px;
  }

  .feed-modal {
    max-height: min(76vh, 560px);
    padding: 12px;
  }
}

@media (max-height: 760px) {
  .app-shell {
    gap: 9px;
    padding:
      calc(10px + var(--safe-top))
      calc(14px + var(--safe-right))
      calc(14px + var(--safe-bottom))
      calc(14px + var(--safe-left));
  }

  .office-strip {
    height: 66px;
  }

  .stats {
    gap: 6px;
  }

  .choice-button {
    min-height: clamp(60px, 11dvh, 78px);
    padding: 10px 11px;
    gap: 6px;
  }
}
