:root {
  --eazo-safe-area-top: max(56px, env(safe-area-inset-top, 0px));
  --eazo-safe-area-bottom: max(34px, env(safe-area-inset-bottom, 0px));
  --bg: #001818;
  --bg2: #000018;
  --concrete: #161a19;
  --concrete2: #232827;
  --line: rgba(245, 245, 245, .42);
  --line-hard: #f5f5f5;
  --ink: #f5f5f5;
  --muted: rgba(245, 245, 245, .66);
  --dim: rgba(245, 245, 245, .38);
  --rust: #c07848;
  --danger: #ff6d4a;
  --cell-gap: 3px;
  --shadow: 0 30px 90px rgba(0, 0, 0, .45);
  font-family: "Arial Black", Arial, Helvetica, sans-serif;
}

* { box-sizing: border-box; }
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  clip: rect(0 0 0 0); clip-path: inset(50%);
  overflow: hidden; white-space: nowrap;
}
html, body { min-height: 100%; margin: 0; background: var(--bg); color: var(--ink); overflow-x: hidden; }
body { touch-action: manipulation; }
button { font: inherit; color: inherit; }
img { display: block; }

.app {
  min-height: 100vh;
  min-height: 100dvh;
  padding-top: var(--eazo-safe-area-top);
  padding-bottom: var(--eazo-safe-area-bottom);
  position: relative;
  background:
    radial-gradient(circle at 70% 16%, rgba(192, 120, 72, .32), transparent 16rem),
    radial-gradient(circle at 19% 34%, rgba(245, 245, 245, .16), transparent 9rem),
    radial-gradient(circle at 52% 74%, rgba(0, 72, 48, .75), transparent 18rem),
    linear-gradient(135deg, #001818 0%, #000018 100%);
  isolation: isolate;
}

.app::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  opacity: .55;
  background-image:
    linear-gradient(rgba(245, 245, 245, .035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(245, 245, 245, .035) 1px, transparent 1px),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, .035) 0 1px, transparent 1px 4px);
  background-size: 42px 42px, 42px 42px, 100% 5px;
  mix-blend-mode: screen;
}

.wrap {
  width: min(100%, 1120px);
  margin: 0 auto;
  padding: 0 12px 12px;
  display: grid;
  gap: 12px;
  min-width: 0;
}

/* ---- TOPBAR ---- */
.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: stretch;
  border: 2px solid var(--line-hard);
  background: rgba(0, 24, 24, .86);
  box-shadow: var(--shadow);
  min-width: 0;
}
.brand { padding: 10px 10px 8px; min-width: 0; border-right: 2px solid var(--line-hard); }

.kicker, .meta, .hint, .tile-tag, .slot-label, .budget, .poster-meta, .score-copy {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.kicker { font-size: 10px; line-height: 1.2; color: var(--rust); margin-bottom: 2px; }
h1 { margin: 0; font-size: clamp(23px, 7vw, 52px); line-height: .88; text-transform: uppercase; letter-spacing: -.07em; }
.theme-row { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: baseline; margin-top: 6px; min-width: 0; }
.theme { font-size: clamp(12px, 3.3vw, 16px); line-height: 1; text-transform: uppercase; letter-spacing: -.04em; }
.hint { color: var(--muted); font-size: 10px; line-height: 1.25; }
.lang {
  align-self: stretch;
  min-width: 74px;
  min-height: 52px;
  border: 0;
  background: var(--ink);
  color: var(--bg2);
  cursor: pointer;
  font-size: 12px;
  letter-spacing: -.03em;
  text-transform: uppercase;
}
.lang:active { background: var(--rust); }

/* ---- STATUS RAIL ---- */
.status-rail {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-width: 0;
}
.budget {
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, .2);
  padding: 7px 8px;
  font-size: 10px;
  white-space: nowrap;
}
.budget.out { border-color: var(--danger); color: var(--danger); }
.instruction { margin: 0; color: var(--muted); font: 600 11px/1.25 Arial, Helvetica, sans-serif; min-width: 0; }
.shoot {
  min-height: 44px;
  min-width: 74px;
  border: 2px solid var(--line-hard);
  background: var(--rust);
  color: #060606;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 5px 5px 0 #000;
  transition: transform .18s ease, opacity .18s ease;
}
.shoot:not(:disabled):active { transform: translate(3px, 3px); box-shadow: 2px 2px 0 #000; }
.shoot:disabled { opacity: .36; cursor: not-allowed; background: transparent; color: var(--dim); box-shadow: none; }

/* ---- WALL ---- */
.main-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--cell-gap);
  border: 2px solid var(--line-hard);
  background: var(--line-hard);
  box-shadow: var(--shadow);
  min-width: 0;
}
.tile {
  position: relative;
  min-width: 0;
  aspect-ratio: 2 / 3;
  border: 0;
  padding: 0;
  overflow: hidden;
  background: #0d0f0e;
  cursor: pointer;
  touch-action: none;
  display: block;
  -webkit-user-select: none;
  user-select: none;
}
.tile::before {
  content: attr(data-index);
  position: absolute;
  inset: 5px auto auto 5px;
  z-index: 4;
  font-size: clamp(20px, 8vw, 44px);
  line-height: .75;
  letter-spacing: -.12em;
  color: rgba(245, 245, 245, .84);
  text-shadow: 0 2px 8px rgba(0, 0, 0, .5);
  pointer-events: none;
  transition: opacity .3s ease;
}
.tile.revealed::before { opacity: 0; }
.tile-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  -webkit-user-drag: none;
  user-select: none;
}
.tile-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: linear-gradient(160deg, #2a302d, #12100e);
  color: var(--dim);
  font: 9px/1.2 ui-monospace, monospace;
  text-transform: uppercase;
  letter-spacing: .1em;
}
/* frost canvas overlay */
.frost {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.tile.revealed .frost { display: none; }
.tile.revealed::after, .tile.selected::after {
  content: "";
  position: absolute; inset: 0; z-index: 3; pointer-events: none;
  border: 2px solid var(--rust);
}
.tile.selected::after { border-width: 4px; box-shadow: inset 0 0 0 999px rgba(192, 120, 72, .18); }
.tile.budget-locked { cursor: not-allowed; }
.tile-tag {
  position: absolute;
  left: 0; right: 0; bottom: 0; z-index: 5;
  padding: 5px 4px;
  background: rgba(0, 0, 0, .78);
  color: var(--ink);
  font-size: 8px;
  line-height: 1.1;
  opacity: 0;
  transform: translateY(8px);
  transition: .25s ease;
}
.tile.revealed .tile-tag { opacity: 1; transform: translateY(0); }

/* ---- TRAY ---- */
.tray {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: var(--cell-gap);
  border: 2px solid var(--line-hard);
  background: var(--line-hard);
  min-width: 0;
}
.slot {
  min-height: 56px;
  aspect-ratio: 2 / 3;
  border: 0;
  background: rgba(22, 26, 25, .92);
  position: relative;
  overflow: hidden;
  padding: 0;
  cursor: pointer;
  display: block;
}
.slot-label {
  font-size: 9px; color: var(--dim);
  position: absolute; left: 5px; top: 5px; z-index: 3;
  pointer-events: none;
}
.slot.filled .slot-label { color: var(--ink); background: rgba(0, 0, 0, .55); padding: 2px 4px; }
.slot-mini {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  z-index: 1;
}
.slot.filled::after {
  content: ""; position: absolute; inset: 0; z-index: 2; pointer-events: none;
  border: 2px solid var(--rust);
}

/* ---- RESULT / POSTER ---- */
.result {
  display: none;
  border: 2px solid var(--line-hard);
  background: rgba(0, 24, 24, .9);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.result.show { display: grid; gap: 0; animation: resultIn .55s cubic-bezier(.16, 1, .3, 1) both; }
@keyframes resultIn { from { opacity: 0; transform: translateY(18px) scale(.98); } to { opacity: 1; transform: none; } }
.poster { background: #efeee8; color: #050505; padding: 14px; min-width: 0; }
.poster-head { display: flex; justify-content: space-between; gap: 12px; align-items: start; border-bottom: 4px solid #050505; padding-bottom: 8px; }
.poster-title { margin: 0; font-size: clamp(30px, 11vw, 74px); line-height: .78; letter-spacing: -.09em; text-transform: uppercase; max-width: 7ch; }
.poster-meta { font-size: 9px; line-height: 1.35; text-align: right; color: #111; white-space: pre-line; }
.poster-photos { margin-top: 10px; display: grid; grid-template-columns: 1.35fr .65fr; gap: 5px; min-width: 0; }
.hero-photo, .support-photo { position: relative; overflow: hidden; background: #1a1a1a; min-width: 0; animation: slidePhoto .6s cubic-bezier(.16, 1, .3, 1) both; }
.hero-photo { aspect-ratio: 2 / 3; }
.support-stack { display: grid; grid-template-columns: 1fr; gap: 5px; }
.support-photo { aspect-ratio: 2 / 3; }
.hero-photo img, .support-photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.support-photo:nth-child(1) { animation-delay: .05s; }
.support-photo:nth-child(2) { animation-delay: .12s; }
.support-photo:nth-child(3) { animation-delay: .19s; }
.support-photo:nth-child(4) { animation-delay: .26s; }
@keyframes slidePhoto { from { opacity: 0; transform: translateX(18px); } to { opacity: 1; transform: none; } }
.scorebar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 12px;
  border-top: 2px solid var(--line-hard);
  background: #050505;
}
.score-num { font-size: 48px; line-height: .8; letter-spacing: -.08em; color: var(--rust); }
.score-copy { font-size: 11px; line-height: 1.45; color: var(--ink); }
.actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 3px;
  background: var(--line-hard);
  border-top: 2px solid var(--line-hard);
}
.action-btn { min-height: 48px; border: 0; background: var(--concrete); cursor: pointer; text-transform: uppercase; font-size: 11px; padding: 4px; }
.action-btn.primary { background: var(--rust); color: #050505; }
.action-btn:active { background: var(--concrete2); }
.action-btn.primary:active { background: #d38a58; }
.toast { min-height: 20px; padding: 4px 10px; color: var(--rust); font: 10px/1.3 ui-monospace, monospace; text-transform: uppercase; letter-spacing: .08em; }

/* ---- DESKTOP ---- */
@media (min-width: 760px) {
  .wrap { grid-template-columns: minmax(0, .82fr) minmax(300px, .45fr); align-items: start; padding: 0 20px 20px; }
  .topbar, .status-rail, .main-grid, .tray { grid-column: 1; }
  .result { grid-column: 2; grid-row: 1 / span 4; position: sticky; top: var(--eazo-safe-area-top); }
  .result:not(.show) { display: grid; opacity: .5; }
  .main-grid { grid-template-columns: repeat(4, minmax(84px, 1fr)); }
  .slot { min-height: 66px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
