:root {
  --bg: #0a0a0a;
  --panel: #101010;
  --panel-2: #151515;
  --ink: #f3f1ea;
  --muted: #92928d;
  --line: rgba(255,255,255,.12);
  --line-strong: rgba(255,255,255,.24);
  --accent: #e35c2f;
  --cream: #ece8de;
  --success: #4b9f74;
  --near: #c49a4d;
  --miss: #b75c56;
  --font: Inter, -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 82% 0%, rgba(227,92,47,.12), transparent 28rem),
    var(--bg);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}
button, a { font: inherit; color: inherit; }
a { text-decoration: none; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }

.app-shell {
  width: min(1580px, calc(100% - 40px));
  margin: 0 auto;
  padding: 22px 0 56px;
}

.header-topline,
.title-row,
.board-topbar,
.bench-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.header-topline {
  min-height: 38px;
  border-bottom: 1px solid var(--line);
}

.back-link,
.round-chip,
.eyebrow,
.rail-label,
.stats-grid span,
.theme-card > span,
.interaction-note,
.utility-button,
.primary-action,
.secondary-action {
  font-size: .66rem;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
}

.back-link { color: var(--cream); }
.back-link:hover { color: var(--accent); }
.round-chip { color: var(--muted); }
.round-chip strong { margin-left: 6px; color: var(--ink); }

.title-row {
  align-items: flex-end;
  min-height: 310px;
  padding: 38px 0 34px;
}
.title-lockup { min-width: 0; }
.eyebrow { margin: 0 0 12px; color: var(--muted); }
h1, h2, p { margin-top: 0; }
h1 {
  margin: 0;
  font-size: clamp(5.2rem, 10vw, 10rem);
  font-weight: 800;
  line-height: .72;
  letter-spacing: -.075em;
  text-transform: uppercase;
}
.header-side {
  width: min(560px, 42vw);
  padding-bottom: 4px;
}
.game-intro {
  max-width: 28rem;
  margin: 0 0 26px;
  color: #c8c5bd;
  font-size: .95rem;
  line-height: 1.55;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line);
}
.stats-grid article {
  min-height: 74px;
  padding: 13px 12px 12px 0;
  border-right: 1px solid var(--line);
}
.stats-grid article:not(:first-child) { padding-left: 14px; }
.stats-grid article:last-child { border-right: 0; }
.stats-grid span { display: block; color: var(--muted); }
.stats-grid strong {
  display: block;
  margin-top: 8px;
  font-size: 1.65rem;
  font-weight: 500;
  line-height: 1;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(220px, 275px) minmax(0, 1fr);
  gap: 28px;
  align-items: start;
  border-top: 1px solid var(--line);
  padding-top: 28px;
}

.game-rail {
  position: sticky;
  top: 20px;
  min-height: 500px;
  padding-right: 8px;
}
.rail-label {
  margin-bottom: 26px;
  color: var(--accent);
}
.theme-card {
  border-top: 1px solid var(--line-strong);
  padding-top: 18px;
}
.theme-card > span { color: var(--muted); }
.theme-card strong {
  display: block;
  margin: 12px 0 12px;
  font-size: 2rem;
  font-weight: 700;
  line-height: .98;
  letter-spacing: -.03em;
  text-transform: uppercase;
}
.theme-card p {
  margin: 0;
  color: #b4b1aa;
  font-size: .86rem;
  line-height: 1.65;
}
.control-stack {
  display: grid;
  gap: 9px;
  margin-top: 28px;
}
.primary-action,
.secondary-action,
.utility-button {
  min-height: 48px;
  border: 1px solid var(--line-strong);
  padding: 0 15px;
  background: transparent;
  cursor: pointer;
  transition: background .16s ease, color .16s ease, border-color .16s ease, transform .16s ease;
}
.primary-action {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
}
.primary-action:hover { background: #f06a3d; border-color: #f06a3d; }
.secondary-action:hover,
.utility-button:hover { color: #0a0a0a; background: var(--cream); border-color: var(--cream); }
.primary-action:active,
.secondary-action:active,
.utility-button:active { transform: translateY(1px); }
.interaction-note {
  margin: 18px 0 0;
  color: #74746f;
  line-height: 1.6;
  letter-spacing: .1em;
}

.game-board {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--panel);
}
.board-topbar {
  min-height: 78px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
}
.board-topbar h2,
.bench-header h2,
.result-panel h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 650;
  letter-spacing: .01em;
}
.utility-button {
  min-height: 36px;
  border-color: var(--line);
  color: #b6b3ac;
  font-size: .6rem;
}

.tier-board {
  display: grid;
  background: #0d0d0d;
}
.tier-row {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  min-height: 164px;
  border-bottom: 1px solid var(--line);
  background: #101010;
}
.tier-row:last-child { border-bottom: 0; }
.tier-label {
  display: grid;
  place-items: center;
  border-right: 1px solid var(--line);
  color: var(--cream);
  background: #141414;
  font-size: 1.55rem;
  font-weight: 800;
}
.tier-row[data-tier="S"] .tier-label { color: #fff; background: var(--accent); }
.tier-row[data-tier="A"] .tier-label { color: #111; background: var(--cream); }
.tier-row[data-tier="B"] .tier-label { background: #292929; }
.tier-row[data-tier="C"] .tier-label { background: #202020; }
.tier-row[data-tier="D"] .tier-label { background: #171717; }
.drop-zone {
  min-height: 162px;
  padding: 11px;
  display: flex;
  align-items: stretch;
  flex-wrap: wrap;
  gap: 10px;
  transition: background .14s ease;
}
.drop-zone.drag-over { background: rgba(227,92,47,.08); }

.item-card {
  width: 148px;
  min-height: 140px;
  border: 1px solid var(--line);
  padding: 0;
  display: grid;
  grid-template-rows: 108px minmax(34px, auto);
  overflow: hidden;
  color: var(--ink);
  background: #161616;
  cursor: grab;
  text-align: left;
  user-select: none;
  transition: border-color .16s ease, transform .16s ease, opacity .16s ease, box-shadow .16s ease;
}
.item-card:hover {
  z-index: 2;
  border-color: rgba(255,255,255,.5);
  transform: translateY(-3px);
  box-shadow: 0 14px 30px rgba(0,0,0,.28);
}
.item-card:active { cursor: grabbing; }
.item-card.dragging { opacity: .35; }
.item-image-wrap {
  position: relative;
  width: 100%;
  height: 108px;
  display: block;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #272727, #181818);
}
.item-image-wrap::after {
  position: absolute;
  inset: auto 0 0;
  height: 32%;
  content: "";
  background: linear-gradient(to top, rgba(0,0,0,.18), transparent);
  pointer-events: none;
}
.item-image-wrap img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  object-position: center bottom;
  transform: scale(1.12);
  filter: saturate(.95) contrast(1.03);
  transition: transform .18s ease;
}
.item-card:hover .item-image-wrap img { transform: scale(1.16); }
.item-name {
  min-height: 36px;
  padding: 9px 10px 10px;
  display: flex;
  align-items: center;
  color: #f0eee8;
  font-size: .72rem;
  font-weight: 650;
  line-height: 1.15;
}
.item-card.image-failed { min-height: 58px; grid-template-rows: 1fr; }
.item-card.image-failed .item-image-wrap { display: none; }
.item-card.correct { border-color: var(--success); box-shadow: inset 0 -3px 0 var(--success); }
.item-card.close { border-color: var(--near); box-shadow: inset 0 -3px 0 var(--near); }
.item-card.miss { border-color: var(--miss); box-shadow: inset 0 -3px 0 var(--miss); }

.bench-panel {
  border-top: 1px solid var(--line);
  padding: 17px 18px 18px;
  background: #0d0d0d;
}
.bench-header span { color: var(--muted); font-size: .68rem; }
.bench-list {
  min-height: 168px;
  margin-top: 14px;
  padding: 0;
  align-items: flex-start;
}

.result-panel {
  margin: 34px 0 0 303px;
  padding-top: 22px;
  display: grid;
  grid-template-columns: minmax(220px,.5fr) minmax(0,1fr);
  gap: 30px;
  border-top: 1px solid var(--line-strong);
}
.result-copy p:last-child { margin-bottom: 0; color: var(--muted); line-height: 1.55; }
.answer-strip {
  display: grid;
  grid-template-columns: repeat(5,minmax(0,1fr));
  border-left: 1px solid var(--line);
}
.answer-card {
  min-height: 90px;
  border: 1px solid var(--line);
  border-left: 0;
  padding: 12px;
  background: #101010;
}
.answer-card span {
  display: block;
  margin-bottom: 8px;
  color: var(--accent);
  font-weight: 800;
}
.answer-card small {
  color: #8e8d88;
  font-size: .68rem;
  line-height: 1.45;
}

@media (max-width: 1180px) {
  .title-row { min-height: 250px; }
  .header-side { width: min(500px,45vw); }
  .game-layout { grid-template-columns: 230px minmax(0,1fr); gap: 22px; }
  .item-card { width: 132px; }
  .result-panel { margin-left: 252px; }
}

@media (max-width: 980px) {
  .app-shell { width: min(100% - 28px,1580px); }
  .title-row { align-items: flex-end; }
  .header-side { width: 48vw; }
  .game-layout { grid-template-columns: 1fr; }
  .game-rail {
    position: static;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0,1fr) 300px;
    gap: 22px;
    align-items: end;
    padding-right: 0;
  }
  .rail-label { grid-column: 1 / -1; margin-bottom: -4px; }
  .control-stack { margin-top: 0; }
  .interaction-note { grid-column: 1 / -1; margin-top: -8px; }
  .result-panel { margin-left: 0; }
}

@media (max-width: 720px) {
  body { background: var(--bg); }
  .app-shell { width: 100%; padding: 12px 10px 32px; }
  .header-topline { min-height: 34px; }
  .title-row { display: block; min-height: 0; padding: 30px 0 24px; }
  h1 { font-size: clamp(4.6rem,25vw,7rem); }
  .header-side { width: 100%; margin-top: 28px; }
  .game-intro { margin-bottom: 20px; }
  .stats-grid article { min-height: 66px; padding-top: 12px; }
  .stats-grid strong { font-size: 1.35rem; }
  .game-rail { display: block; }
  .rail-label { margin-bottom: 18px; }
  .control-stack { grid-template-columns: 1fr 1fr; margin-top: 20px; }
  .tier-row { grid-template-columns: 42px minmax(0,1fr); min-height: 142px; }
  .tier-label { font-size: 1.2rem; }
  .drop-zone {
    min-height: 140px;
    padding: 8px;
    flex-wrap: nowrap;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
  }
  .drop-zone::-webkit-scrollbar { display: none; }
  .item-card {
    width: 116px;
    flex: 0 0 116px;
    min-height: 122px;
    grid-template-rows: 88px minmax(34px,auto);
  }
  .item-image-wrap { height: 88px; }
  .board-topbar { min-height: 68px; padding: 12px; }
  .board-topbar h2 { max-width: 15rem; font-size: .9rem; }
  .utility-button { min-height: 34px; padding: 0 10px; }
  .bench-panel { padding: 15px 12px 16px; }
  .bench-list { min-height: 140px; }
  .result-panel { grid-template-columns: 1fr; gap: 18px; }
  .answer-strip { grid-template-columns: 1fr; }
  .answer-card { min-height: auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition: none !important;
    animation: none !important;
  }
}
