:root {
  --ink: #14283b;
  --muted: #647184;
  --paper: #fff8ea;
  --panel: #ffffff;
  --line: rgba(20, 40, 59, 0.16);
  --blue: #20aee9;
  --blue-dark: #087fbd;
  --orange: #f58219;
  --yellow: #fff0c9;
  --green: #18855b;
  --red: #c93f47;
  --teal: #158f94;
  --shadow: 0 22px 60px rgba(20, 40, 59, 0.16);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

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

body {
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  background:
    linear-gradient(90deg, rgba(20, 40, 59, 0.055) 1px, transparent 1px),
    linear-gradient(rgba(20, 40, 59, 0.055) 1px, transparent 1px),
    linear-gradient(135deg, #fff8ea 0%, #eef9fd 52%, #fff2d7 100%);
  background-size: 32px 32px, 32px 32px, auto;
}

button {
  font: inherit;
  touch-action: manipulation;
}

.app-shell {
  display: grid;
  width: min(1160px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 16px clamp(12px, 3vw, 28px) 20px;
  gap: 12px;
}

.game-header,
.game-footer,
.header-actions,
.controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.game-header,
.game-footer {
  justify-content: space-between;
}

.brand-lockup {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  width: 48px;
  height: auto;
  flex: 0 0 auto;
}

.brand-name,
.brand-subtitle {
  display: block;
}

.brand-name {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.brand-subtitle {
  font-size: clamp(1.35rem, 4vw, 2.35rem);
  font-weight: 900;
  line-height: 1;
}

.tool-link,
.primary-btn,
.secondary-btn,
.mode-btn {
  min-height: 44px;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  color: var(--ink);
  font-weight: 900;
  text-decoration: none;
  cursor: pointer;
}

.tool-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 3px 3px 0 var(--ink);
}

.button-link {
  appearance: none;
}

.hud-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.hud-item {
  display: grid;
  min-height: 66px;
  place-items: center;
  padding: 10px 8px;
  background: rgba(255, 255, 255, 0.86);
  border: 2px solid var(--line);
  border-radius: var(--radius);
}

.hud-item strong {
  font-size: clamp(1.1rem, 4vw, 2rem);
  line-height: 1;
}

.hud-item span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.mode-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.mode-btn {
  padding: 8px;
  background: rgba(255, 255, 255, 0.82);
}

.mode-btn.active {
  color: #ffffff;
  background: var(--ink);
}

.game-stage {
  display: grid;
  grid-template-columns: minmax(270px, 0.85fr) minmax(320px, 1.15fr);
  gap: 14px;
  min-height: 520px;
}

.scene-panel,
.challenge-card,
.overlay-panel {
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.scene-panel {
  position: relative;
  min-height: 440px;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(20, 40, 59, 0.95), rgba(15, 45, 61, 0.96)),
    #14283b;
}

.scene-title {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  z-index: 2;
  padding: 12px 14px;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius);
}

.scene-title strong,
.scene-title span {
  display: block;
}

.scene-title span {
  margin-top: 4px;
  color: rgba(255, 255, 255, 0.76);
  font-size: 0.92rem;
  font-weight: 700;
}

.scene-art {
  position: absolute;
  inset: 105px 16px 16px;
  display: grid;
  place-items: center;
}

.phone,
.story-stack,
.receipt-card {
  width: min(100%, 320px);
  border: 3px solid #ffffff;
  border-radius: var(--radius);
  background: #ffffff;
  box-shadow: 9px 9px 0 rgba(0, 0, 0, 0.22);
}

.phone {
  min-height: 310px;
  padding: 14px;
  background: #101f30;
}

.phone-bar {
  width: 88px;
  height: 8px;
  margin: 0 auto 18px;
  background: rgba(255, 255, 255, 0.42);
  border-radius: 99px;
}

.phone-label {
  width: fit-content;
  max-width: 92%;
  margin: 4px 0 8px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.bubble {
  width: fit-content;
  max-width: 92%;
  margin: 10px 0;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--ink);
  background: #e8f6fc;
  font-weight: 800;
}

.bubble.right {
  margin-left: auto;
  color: #ffffff;
  background: var(--blue-dark);
}

.story-stack,
.receipt-card {
  display: grid;
  gap: 10px;
  padding: 16px;
}

.story-stack {
  counter-reset: story-step;
}

.story-strip,
.receipt-line {
  padding: 12px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: #f7fbfd;
  font-weight: 900;
}

.story-strip {
  display: flex;
  align-items: center;
  gap: 10px;
}

.story-strip span {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  color: #ffffff;
  background: var(--blue-dark);
  border-radius: 50%;
  font-size: 0.92rem;
}

.story-strip strong {
  font-size: 1.08rem;
}

.receipt-line.marked {
  border-color: var(--orange);
  background: #fff0c9;
}

.challenge-card {
  display: flex;
  flex-direction: column;
  padding: clamp(18px, 4vw, 28px);
  background: rgba(255, 255, 255, 0.96);
}

.kicker {
  margin: 0 0 8px;
  color: var(--blue-dark);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

.challenge-card h1,
.overlay-panel h2 {
  font-size: clamp(1.7rem, 5vw, 3rem);
  line-height: 1.04;
}

.challenge-copy,
.overlay-panel p {
  margin-top: 12px;
  color: var(--muted);
  font-size: 1.05rem;
  font-weight: 700;
}

.answer-area {
  display: grid;
  gap: 10px;
  margin: 22px 0 16px;
}

.answer-btn,
.order-item {
  width: 100%;
  min-height: 64px;
  padding: 14px 16px;
  color: var(--ink);
  background: #f7fbfd;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  font-weight: 900;
  text-align: left;
  cursor: pointer;
  transition: transform 150ms ease, border-color 150ms ease, background 150ms ease;
}

.answer-btn:hover,
.order-item:hover {
  border-color: var(--blue);
  transform: translateY(-1px);
}

.answer-btn.is-correct,
.order-item.is-correct {
  background: #e5f8e8;
  border-color: var(--green);
}

.answer-btn.is-wrong,
.order-item.is-wrong {
  background: #fff0e8;
  border-color: var(--orange);
}

.order-help {
  margin-bottom: 10px;
  color: var(--muted);
  font-weight: 800;
}

.order-list {
  display: grid;
  gap: 10px;
}

.feedback {
  min-height: 34px;
  margin-top: auto;
  color: var(--ink);
  font-weight: 900;
}

.feedback.good {
  color: var(--green);
}

.feedback.bad {
  color: var(--red);
}

.controls {
  flex-wrap: wrap;
  margin-top: 12px;
}

.controls.center {
  justify-content: center;
}

.primary-btn,
.secondary-btn {
  padding: 12px 18px;
}

.primary-btn {
  background: var(--orange);
  box-shadow: 4px 4px 0 var(--ink);
}

.primary-btn:disabled {
  color: var(--muted);
  background: #e9edf0;
  box-shadow: none;
  cursor: not-allowed;
}

.secondary-btn {
  background: #ffffff;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  place-items: center;
  padding: 18px;
  background: rgba(20, 40, 59, 0.72);
}

.overlay.show {
  display: grid;
}

.overlay-panel {
  width: min(620px, 100%);
  padding: clamp(22px, 5vw, 34px);
  background: #ffffff;
  text-align: center;
}

.mini-rules,
.result-stats {
  display: grid;
  gap: 10px;
  margin: 20px 0;
}

.mini-rules {
  grid-template-columns: repeat(3, 1fr);
}

.mini-rules span,
.result-stats div {
  padding: 12px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: #f7fbfd;
  font-weight: 900;
}

.result-stats {
  grid-template-columns: repeat(3, 1fr);
}

.result-stats strong,
.result-stats span {
  display: block;
}

.result-stats strong {
  font-size: 2rem;
}

.result-stats span {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.result-guidance {
  padding: 14px;
  color: var(--ink);
  background: #fff8ea;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  font-weight: 800;
}

.game-footer {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.studio-credit a {
  color: var(--blue-dark);
  font-weight: 900;
  text-decoration: none;
}

.studio-credit a:hover {
  color: var(--ink);
}

@media (max-width: 820px) {
  .game-header,
  .game-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .hud-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mode-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .game-stage {
    grid-template-columns: 1fr;
  }

  .scene-panel {
    min-height: 330px;
  }

  .scene-art {
    top: 92px;
  }
}

@media (max-width: 460px) {
  .header-actions,
  .controls,
  .mini-rules,
  .result-stats {
    grid-template-columns: 1fr;
  }

  .header-actions {
    align-items: stretch;
    flex-direction: column;
    width: 100%;
  }

  .tool-link {
    width: 100%;
  }
}
