:root {
  color-scheme: light;
  --ink: #17211e;
  --muted: #62716b;
  --line: #d6ddd8;
  --panel: #ffffff;
  --surface: #f4f1ea;
  --leaf: #1f6657;
  --leaf-strong: #16483f;
  --leaf-soft: #dbece3;
  --amber: #d99225;
  --amber-soft: #fff0ce;
  --sky: #d9e9ef;
  --terracotta: #a95437;
  --danger: #a33828;
  --shadow: 0 16px 42px rgba(23, 33, 30, 0.14);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  background:
    linear-gradient(180deg, #e8f1ed 0, rgba(232, 241, 237, 0) 360px),
    var(--surface);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.app-shell {
  width: min(100%, 860px);
  min-height: 100svh;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) 12px max(24px, env(safe-area-inset-bottom));
}

.hero,
.login-hero {
  position: relative;
  min-height: 214px;
  overflow: hidden;
  border-radius: 8px;
  background: var(--leaf-strong);
  box-shadow: var(--shadow);
  isolation: isolate;
}

.hero picture,
.hero img,
.login-hero picture,
.login-hero img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.hero img,
.login-hero img {
  object-fit: cover;
}

.hero-shade {
  position: absolute;
  inset: 0;
  z-index: 1;
  background:
    linear-gradient(90deg, rgba(17, 28, 25, 0.78), rgba(17, 28, 25, 0.34) 54%, rgba(17, 28, 25, 0.10)),
    linear-gradient(0deg, rgba(17, 28, 25, 0.45), rgba(17, 28, 25, 0.05) 52%);
}

.hero-copy {
  position: absolute;
  left: clamp(16px, 5vw, 34px);
  right: 74px;
  bottom: clamp(16px, 4vw, 28px);
  z-index: 2;
  color: #ffffff;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--amber);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

.hero h1,
.login-hero h1 {
  max-width: 12ch;
  margin: 0;
  color: #ffffff;
  font-size: clamp(2.45rem, 12vw, 5.35rem);
  line-height: 0.9;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 13px;
}

.hero-meta span {
  min-height: 30px;
  border: 1px solid rgba(255, 255, 255, 0.38);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.16);
  padding: 6px 9px;
  color: #ffffff;
  font-size: 0.81rem;
  font-weight: 850;
  backdrop-filter: blur(12px);
}

.logout-button {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 3;
  border-color: rgba(255, 255, 255, 0.38);
  background: rgba(255, 255, 255, 0.16);
  color: #ffffff;
  backdrop-filter: blur(12px);
}

.view-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin: 12px 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  padding: 6px;
}

.tab-button {
  display: grid;
  grid-template-columns: 21px minmax(0, auto);
  justify-content: center;
  align-items: center;
  gap: 7px;
  min-height: 46px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 900;
  cursor: pointer;
}

.tab-button span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.tab-button.is-active {
  background: var(--leaf);
  color: #ffffff;
}

.status-line {
  min-height: 22px;
  margin: 0 2px 10px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.status-line.is-busy {
  color: var(--terracotta);
}

.status-line.is-done {
  color: var(--leaf);
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 18px 2px 10px;
}

.section-head h2 {
  margin: 0;
  font-size: 1.22rem;
  line-height: 1.1;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.storage-chip,
.stamp-badge {
  display: grid;
  min-height: 36px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 7px 10px;
  color: var(--leaf-strong);
  font-size: 0.8rem;
  font-weight: 900;
  white-space: nowrap;
}

.upload-tool,
.challenge-tool,
.story-tool,
.bingo-tool,
.login-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 12px 34px rgba(23, 33, 30, 0.09);
}

.upload-tool {
  padding: 12px;
}

.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.picker-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.picker-grid.is-dragging .picker {
  border-color: var(--leaf);
  background: var(--leaf-soft);
}

.picker {
  display: flex;
  min-height: 96px;
  align-items: center;
  gap: 14px;
  border: 1px dashed #a8b3ae;
  border-radius: 8px;
  background: #fbfcf8;
  padding: 16px;
  cursor: pointer;
}

.picker-icon {
  display: grid;
  flex: 0 0 54px;
  width: 54px;
  height: 54px;
  place-items: center;
  border-radius: 8px;
  background: var(--leaf);
  color: #ffffff;
}

.picker-icon.is-amber {
  background: var(--amber);
  color: #25180a;
}

.picker strong,
.picker small {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
}

.picker strong {
  color: var(--ink);
  font-size: 1.12rem;
  line-height: 1;
}

.picker small {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 760;
}

.memory-fields {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 12px;
}

.field {
  display: grid;
  gap: 7px;
}

.field span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 900;
}

.field input,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  padding: 12px 13px;
  font-size: 1rem;
}

.field input {
  min-height: 48px;
}

.field textarea {
  min-height: 92px;
  resize: vertical;
}

.field input:focus,
.field textarea:focus {
  border-color: var(--leaf);
  outline: 3px solid rgba(31, 102, 87, 0.17);
}

.queue {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.queue:empty {
  display: none;
}

.file-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 10px;
}

.file-name,
.file-size,
.upload-status,
.memory-note,
.memory-stage,
.empty,
.dialog-note,
.challenge-text {
  overflow-wrap: anywhere;
}

.file-name {
  min-width: 0;
  color: var(--ink);
  font-size: 0.94rem;
  font-weight: 850;
}

.file-size,
.upload-status {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.progress-wrap {
  margin-top: 14px;
}

.progress-track {
  width: 100%;
  height: 14px;
  overflow: hidden;
  border-radius: 8px;
  background: #e2e7e0;
}

.progress-bar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--leaf), var(--amber));
  transition: width 140ms ease-out;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 7px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
}

.actions,
.challenge-actions,
.dialog-actions {
  display: grid;
  gap: 10px;
}

.actions {
  grid-template-columns: minmax(0, 1fr) 52px;
  margin-top: 12px;
}

.challenge-actions,
.dialog-actions {
  grid-template-columns: 1fr 1fr;
}

.primary-button,
.secondary-button,
.ghost-button,
.ghost-label-button,
.icon-button,
.danger-button {
  display: grid;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  border-radius: 8px;
  font-weight: 900;
  text-decoration: none;
  cursor: pointer;
}

.primary-button,
.secondary-button,
.ghost-label-button,
.danger-button {
  grid-template-columns: 21px minmax(0, auto);
  gap: 8px;
  padding: 0 14px;
}

.primary-button {
  border: 0;
  background: var(--leaf);
  color: #ffffff;
}

.primary-button:disabled,
.ghost-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.secondary-button,
.ghost-label-button,
.ghost-button,
.icon-button,
.danger-button {
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
}

.secondary-button,
.ghost-label-button {
  font-size: 0.88rem;
}

.danger-button {
  border-color: rgba(163, 56, 40, 0.35);
  color: var(--danger);
}

.icon-button {
  width: 46px;
  min-height: 46px;
  padding: 0;
}

.primary-button:not(:disabled):active,
.secondary-button:not(:disabled):active,
.ghost-button:not(:disabled):active,
.ghost-label-button:not(:disabled):active,
.icon-button:not(:disabled):active,
.danger-button:not(:disabled):active {
  transform: translateY(1px);
}

.game-board {
  display: grid;
  gap: 12px;
}

.challenge-tool,
.story-tool,
.bingo-tool {
  padding: 12px;
}

.challenge-tool {
  background:
    linear-gradient(135deg, rgba(31, 102, 87, 0.10), rgba(217, 146, 37, 0.16)),
    #ffffff;
}

.challenge-top,
.tool-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.challenge-mode {
  margin: 0 0 5px;
  color: var(--terracotta);
  font-size: 0.78rem;
  font-weight: 950;
  text-transform: uppercase;
}

.challenge-tool h3,
.story-tool h3,
.bingo-tool h3 {
  margin: 0;
  font-size: 1.06rem;
  line-height: 1.15;
  letter-spacing: 0;
}

.stamp-badge {
  min-width: 44px;
  border-color: rgba(217, 146, 37, 0.42);
  background: var(--amber-soft);
  color: #61410c;
}

.challenge-text {
  min-height: 118px;
  margin: 15px 0;
  border: 1px solid rgba(31, 102, 87, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.64);
  padding: 16px;
  color: var(--ink);
  font-size: 1.28rem;
  line-height: 1.22;
  font-weight: 850;
}

.story-lines {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.story-line {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcf8;
  padding: 11px;
}

.story-line span {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.story-line strong {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

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

.bingo-cell {
  display: grid;
  min-height: 76px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcf8;
  padding: 7px;
  color: var(--ink);
  font-size: clamp(0.65rem, 2.7vw, 0.82rem);
  font-weight: 860;
  line-height: 1.1;
  text-align: center;
  cursor: pointer;
  overflow-wrap: anywhere;
}

.bingo-cell.is-marked {
  border-color: rgba(31, 102, 87, 0.5);
  background: var(--leaf);
  color: #ffffff;
}

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

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

.memory-card {
  display: grid;
  grid-template-rows: auto minmax(92px, auto) auto;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.memory-thumb {
  position: relative;
  display: grid;
  width: 100%;
  aspect-ratio: 1 / 0.78;
  place-items: center;
  overflow: hidden;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background:
    linear-gradient(135deg, rgba(217, 146, 37, 0.18), rgba(217, 233, 239, 0.86)),
    #eef3ef;
  color: var(--ink);
  cursor: pointer;
}

.memory-thumb img,
.memory-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.file-glyph {
  display: grid;
  width: 62px;
  height: 78px;
  place-items: center;
  border: 1px solid #cbd4d0;
  border-radius: 6px;
  background: #ffffff;
  color: var(--leaf-strong);
  font-size: 0.74rem;
  font-weight: 950;
}

.memory-thumb video + .file-glyph {
  position: absolute;
  right: 8px;
  bottom: 8px;
  width: auto;
  height: auto;
  min-width: 42px;
  padding: 7px 9px;
  border-color: rgba(255, 255, 255, 0.72);
  background: rgba(23, 33, 30, 0.74);
  color: #ffffff;
}

.memory-info {
  min-width: 0;
  padding: 10px;
}

.memory-stage {
  margin: 0 0 5px;
  color: var(--terracotta);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.memory-note {
  display: -webkit-box;
  min-height: 38px;
  margin: 7px 0 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
  line-height: 1.25;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.memory-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  border-top: 1px solid var(--line);
  background: var(--line);
}

.memory-action {
  min-height: 42px;
  border: 0;
  border-radius: 0;
  background: #ffffff;
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 900;
  cursor: pointer;
}

.memory-action.is-danger {
  color: var(--danger);
}

.memory-action:disabled {
  opacity: 0.56;
}

.empty {
  grid-column: 1 / -1;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  padding: 18px;
  color: var(--muted);
  font-weight: 800;
}

.preview-dialog {
  width: min(940px, calc(100vw - 22px));
  max-height: calc(100svh - 22px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  padding: 0;
  box-shadow: var(--shadow);
}

.preview-dialog::backdrop {
  background: rgba(23, 33, 30, 0.52);
}

.dialog-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 46px;
  gap: 10px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding: 12px;
}

.dialog-head strong,
.dialog-head span {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
}

.dialog-head strong {
  font-size: 0.98rem;
}

.dialog-head span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.dialog-body {
  display: grid;
  min-height: 230px;
  max-height: calc(100svh - 240px);
  place-items: center;
  overflow: auto;
  background: #111916;
}

.preview-media {
  display: block;
  max-width: 100%;
  max-height: calc(100svh - 258px);
  object-fit: contain;
}

.preview-audio {
  width: min(92%, 620px);
}

.preview-frame {
  width: 100%;
  height: min(68svh, 720px);
  border: 0;
  background: #ffffff;
}

.preview-file {
  display: grid;
  gap: 14px;
  place-items: center;
  color: #ffffff;
  padding: 32px;
  text-align: center;
}

.preview-file .file-glyph {
  width: 78px;
  height: 96px;
}

.dialog-note {
  display: none;
  border-top: 1px solid var(--line);
  padding: 12px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 760;
  line-height: 1.35;
}

.dialog-note.has-note {
  display: block;
}

.dialog-actions {
  border-top: 1px solid var(--line);
  padding: 12px;
}

.login-shell {
  display: grid;
  align-content: center;
  gap: 12px;
}

.login-hero {
  min-height: 250px;
}

.login-panel {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.form-error {
  border: 1px solid rgba(163, 56, 40, 0.36);
  border-radius: 8px;
  background: rgba(163, 56, 40, 0.08);
  color: var(--danger);
  padding: 10px 12px;
  font-size: 0.88rem;
  font-weight: 850;
}

@media (max-width: 390px) {
  .app-shell {
    padding-left: 9px;
    padding-right: 9px;
  }

  .hero,
  .login-hero {
    min-height: 198px;
  }

  .hero-copy {
    right: 60px;
  }

  .tab-button {
    grid-template-columns: 1fr;
    gap: 3px;
    font-size: 0.75rem;
  }

  .bingo-cell {
    min-height: 68px;
    padding: 5px;
  }

  .secondary-button,
  .ghost-label-button,
  .danger-button {
    padding: 0 10px;
    font-size: 0.82rem;
  }
}

@media (min-width: 680px) {
  .app-shell {
    padding-top: 22px;
  }

  .hero {
    min-height: 280px;
  }

  .login-hero {
    min-height: 320px;
  }

  .upload-tool,
  .challenge-tool,
  .story-tool,
  .bingo-tool,
  .login-panel {
    padding: 16px;
  }

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

  .game-board {
    grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr);
    align-items: start;
  }

  .bingo-tool {
    grid-column: 1 / -1;
  }

  .memory-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
