:root {
  --ink: #181a1f;
  --paper: #f3efe5;
  --surface: #fffdf7;
  --muted: #696b72;
  --line: #d1ccbf;
  --blue: #3157d5;
  --blue-dark: #2544aa;
  --yellow: #ffd34f;
  --green: #24754f;
  --green-soft: #dcedda;
  --orange: #e97342;
  --red: #bd4934;
}

html {
  background: var(--paper);
}

body {
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 12%, rgb(255 211 79 / 0.22), transparent 24rem),
    radial-gradient(circle at 93% 90%, rgb(49 87 213 / 0.12), transparent 30rem),
    var(--paper);
}

body.has-open-dialog {
  position: fixed;
  right: 0;
  left: 0;
  width: 100%;
  overflow: hidden;
}

.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 76px;
  padding: 14px max(20px, calc((100vw - 960px) / 2));
  color: #fff;
  background: var(--blue);
}

.brand-group {
  display: flex;
  align-items: center;
  justify-self: start;
  gap: 13px;
}

.menu-button {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid rgb(255 255 255 / 0.42);
  border-radius: 9px;
  color: #fff;
  background: transparent;
  font-size: 18px;
}

.logo {
  color: #fff;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: -0.075em;
  text-decoration: none;
}

.page-layout {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 22px;
  width: min(1320px, calc(100% - 20px));
  margin: 0 auto;
}

[data-ad-state="disabled"] {
  display: none;
}

.ad-rail {
  position: sticky;
  top: 20px;
  flex: 0 0 160px;
  min-height: 600px;
  margin-top: 36px;
  padding: 8px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: rgb(255 253 247 / 0.5);
  text-align: center;
}

.ad-rail-right {
  flex-basis: 300px;
}

.ad-rail > span {
  font-size: 10px;
  letter-spacing: 0.12em;
}

.logo span {
  display: inline-block;
  margin-left: 3px;
  padding: 1px 5px;
  color: var(--ink);
  background: var(--yellow);
  transform: rotate(-3deg);
}

.daily-number,
.category,
.round-meta span,
.summary-stats span {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.13em;
}

.daily-number {
  justify-self: center;
}

.topbar nav {
  display: flex;
  align-items: center;
  justify-self: end;
  gap: 18px;
}

.help-button {
  padding: 8px 0;
  border: 0;
  color: #e9edff;
  background: transparent;
  font-size: 13px;
}

.corp-link {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid rgb(255 255 255 / 0.42);
  border-radius: 11px;
  background: rgb(23 48 145 / 0.22);
  text-decoration: none;
  transition: background 160ms ease, transform 160ms ease;
}

.corp-link:hover {
  background: rgb(23 48 145 / 0.45);
  transform: translateY(-1px);
}

.corp-link img {
  display: block;
  width: 34px;
  height: 34px;
}

.game-shell {
  flex: 0 1 760px;
  width: min(760px, calc(100% - 32px));
  margin: 0 auto;
  padding: clamp(35px, 7vw, 70px) 0 72px;
}

.round-meta {
  display: grid;
  grid-template-columns: 110px 1fr 110px;
  align-items: end;
  gap: 25px;
}

.round-meta > div:last-child {
  text-align: right;
}

.round-meta span,
.round-meta strong {
  display: block;
}

.round-meta span {
  color: var(--muted);
}

.round-meta strong {
  margin-top: 3px;
  font-size: 20px;
  font-variant-numeric: tabular-nums;
}

.round-track {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  padding-bottom: 6px;
}

.round-track span {
  height: 5px;
  background: #d9d4c8;
}

.round-track span.is-current,
.round-track span.is-complete {
  background: var(--blue);
}

.prompt {
  padding: clamp(40px, 8vw, 70px) 0 26px;
  text-align: center;
}

.category {
  margin: 0 0 8px;
  color: var(--blue);
}

.prompt h1,
.summary h1 {
  margin: 0;
  font-size: clamp(42px, 7vw, 65px);
  font-weight: 800;
  line-height: 0.98;
  letter-spacing: -0.055em;
}

.prompt > p:last-child {
  margin: 13px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.prompt > p span {
  color: var(--ink);
  font-weight: 700;
}

.lineup-list {
  display: grid;
  gap: 9px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: position;
}

.lineup-card {
  counter-increment: position;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 76px;
  padding: 11px 15px;
  border: 1px solid var(--line);
  border-radius: 15px;
  color: var(--ink);
  background: var(--surface);
  text-align: left;
  touch-action: pan-y;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  box-shadow: 0 4px 0 rgb(36 32 25 / 0.06);
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

body.is-dragging {
  user-select: none;
}

.lineup-card::before {
  content: counter(position);
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  color: #fff;
  background: var(--blue);
  font-weight: 800;
}

.lineup-card:hover:not(:disabled) {
  transform: translateY(-2px);
}

.lineup-card.is-selected {
  border-color: var(--blue);
  box-shadow: inset 0 0 0 2px var(--blue), 0 4px 0 rgb(36 32 25 / 0.06);
  transform: translateX(5px);
}

.lineup-card.is-drag-origin {
  opacity: 0.3;
  transform: scale(0.985);
}

.lineup-card.is-drop-target {
  border-color: var(--orange);
  box-shadow: inset 0 0 0 2px var(--orange), 0 4px 0 rgb(36 32 25 / 0.06);
  transform: translateX(5px);
}

.lineup-card.drag-ghost {
  position: fixed;
  z-index: 1000;
  margin: 0;
  pointer-events: none;
  opacity: 0.96;
  box-shadow: 0 20px 45px rgb(27 30 43 / 0.24);
  transform: rotate(1.5deg) scale(1.02);
}

.lineup-card.drag-ghost::before {
  content: "↕";
}

.lineup-card.is-correct {
  border-color: #a9cba8;
  background: var(--green-soft);
}

.lineup-card.is-correct::before {
  content: "✓";
  background: var(--green);
}

.lineup-card:disabled {
  opacity: 1;
}

.item-copy strong,
.item-copy small {
  display: block;
}

.item-copy strong {
  overflow: hidden;
  font-size: 16px;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-copy small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.drag-mark {
  display: grid;
  grid-template-columns: repeat(2, 3px);
  gap: 4px;
  place-content: center;
  width: 44px;
  height: 44px;
  margin: -6px -7px -6px 0;
  touch-action: none;
  cursor: grab;
}

.drag-mark span {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #aaa79f;
}

.status {
  min-height: 42px;
  margin: 13px 2px 5px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

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

.status.is-warning {
  color: var(--red);
}

.action-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 9px;
}

.secondary-button,
.check-button,
.share-button {
  min-height: 52px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.1em;
  touch-action: manipulation;
}

.secondary-button {
  padding: 0 18px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: var(--surface);
  letter-spacing: 0;
}

.secondary-button:disabled {
  opacity: 0.45;
}

.check-button,
.share-button {
  border: 0;
  color: #fff;
  background: var(--blue);
  transition: background 140ms ease, transform 80ms ease;
}

.check-button:hover,
.share-button:hover {
  background: var(--blue-dark);
}

.secondary-button:active,
.check-button:active,
.share-button:active,
.summary-secondary:active {
  transform: scale(0.985);
}

.answer-reveal {
  margin-top: 30px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgb(255 253 247 / 0.68);
}

.ad-slot {
  min-height: 100px;
  margin-top: 34px;
  padding: 10px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  text-align: center;
}

.ad-slot > span {
  display: block;
  margin-bottom: 8px;
  font-size: 10px;
  letter-spacing: 0.12em;
}

.answer-row {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

.answer-row:last-child {
  border-bottom: 0;
}

.answer-row span:first-child {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.answer-row strong {
  font-weight: 750;
}

.answer-row span:last-child {
  color: var(--blue);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.summary {
  max-width: 680px;
  margin: 0 auto;
  padding: clamp(35px, 7vw, 65px);
  border-radius: 26px;
  color: #fff;
  background: var(--blue);
  box-shadow: 0 25px 70px rgb(35 47 88 / 0.24);
  text-align: center;
}

.summary .category {
  color: #d6ddff;
}

.summary-secondary {
  display: grid;
  place-items: center;
  min-height: 48px;
  margin-top: 9px;
  border: 1px solid rgb(255 255 255 / 0.45);
  border-radius: 12px;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-decoration: none;
}

.summary > p:not(.category, .share-status) {
  margin: 15px auto 0;
  color: #e1e6ff;
  line-height: 1.55;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin: 30px 0;
}

.result-tile {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border-radius: 13px;
  color: var(--ink);
  background: var(--yellow);
  font-size: clamp(22px, 5vw, 36px);
  font-weight: 900;
}

.result-tile.checks-1 {
  background: #91d8a4;
}

.result-tile.checks-2 {
  background: var(--yellow);
}

.result-tile.checks-3 {
  background: #f1a06f;
}

.result-tile.is-failed {
  color: #fff;
  background: var(--red);
}

.summary-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-bottom: 24px;
  overflow: hidden;
  border: 1px solid rgb(255 255 255 / 0.72);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 8px 24px rgb(18 32 86 / 0.2);
}

.summary-stats div {
  padding: 15px 8px;
  border-right: 1px solid var(--line);
}

.summary-stats div:last-child {
  border-right: 0;
}

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

.summary-stats span {
  color: var(--blue-dark);
}

.summary-stats strong {
  margin-top: 5px;
  color: var(--ink);
  font-size: 24px;
  font-variant-numeric: tabular-nums;
}

.share-button {
  width: 100%;
  color: var(--ink);
  background: var(--yellow);
}

.share-button:hover {
  background: #ffdc72;
}

.share-status {
  min-height: 20px;
  margin: 9px 0 0;
  color: #d6ddff;
  font-size: 12px;
}

dialog {
  width: min(500px, calc(100% - 30px));
  max-height: calc(100dvh - 24px);
  padding: 34px;
  overflow-y: auto;
  border: 0;
  border-radius: 20px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 28px 80px rgb(0 0 0 / 0.3);
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

dialog::backdrop {
  background: rgb(16 23 50 / 0.72);
  backdrop-filter: blur(3px);
}

dialog h2 {
  margin: 0;
  font-size: 34px;
  letter-spacing: -0.04em;
}

.menu-dialog {
  width: min(610px, calc(100% - 24px));
}

.dialog-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.dialog-close.is-inline {
  position: static;
  flex: 0 0 38px;
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 24px;
}

.mode-card {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  grid-template-rows: auto auto;
  align-content: center;
  column-gap: 12px;
  row-gap: 4px;
  min-height: 95px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 13px;
  color: var(--ink);
  background: #f7f3e9;
  text-align: left;
  text-decoration: none;
}

.mode-card > span {
  grid-column: 1;
  grid-row: 1 / 3;
  align-self: center;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  color: var(--blue);
  background: #e7ebff;
  font-size: 18px;
  font-weight: 800;
  line-height: 1;
  text-align: center;
}

.mode-card strong,
.mode-card small {
  display: block;
}

.mode-card strong {
  grid-column: 2;
  align-self: end;
  font-size: 14px;
  line-height: 1.2;
}

.mode-card small {
  grid-column: 2;
  align-self: start;
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
}

.archive-list,
.pack-list {
  display: grid;
  gap: 8px;
  margin-top: 22px;
}

.archive-list a,
.pack-list a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 58px;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  background: #f7f3e9;
  text-decoration: none;
}

.archive-list span,
.pack-list span {
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.archive-list .is-complete::after {
  content: "✓";
  color: var(--green);
  font-weight: 900;
}

.archive-empty {
  margin: 0;
  padding: 22px;
  border: 1px dashed var(--line);
  color: var(--muted);
  text-align: center;
}

.dialog-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  margin-top: 24px;
  overflow: hidden;
  border-radius: 12px;
  background: var(--line);
}

.dialog-stats div {
  padding: 16px 10px;
  background: #f7f3e9;
  text-align: center;
}

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

.dialog-stats span {
  min-height: 26px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.08em;
}

.dialog-stats strong {
  margin-top: 4px;
  font-size: 24px;
}

dialog li,
dialog > p:last-child {
  color: #595b61;
  line-height: 1.55;
}

.dialog-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 38px;
  height: 38px;
  border: 0;
  color: var(--ink);
  background: transparent;
  font-size: 28px;
}

@media (max-width: 600px) {
  .topbar {
    grid-template-columns: 1fr auto;
    min-height: 68px;
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
  }

  .daily-number {
    display: none;
  }

  .help-button {
    display: none;
  }

  .game-shell {
    flex: 1 1 auto;
    width: 100%;
    max-width: 520px;
    padding: 24px 0 56px;
  }

  .page-layout {
    width: 100%;
    padding-right: max(14px, env(safe-area-inset-right));
    padding-left: max(14px, env(safe-area-inset-left));
  }

  .round-meta {
    grid-template-columns: 76px minmax(90px, 1fr) 82px;
    gap: 10px;
  }

  .round-meta span {
    font-size: 9px;
    letter-spacing: 0.11em;
  }

  .round-meta strong {
    font-size: 18px;
  }

  .prompt {
    padding: 34px 4px 22px;
  }

  .prompt h1 {
    font-size: clamp(32px, 9.5vw, 40px);
    line-height: 1.01;
    text-wrap: balance;
  }

  .prompt > p:last-child {
    margin-top: 12px;
    font-size: 12px;
    line-height: 1.45;
  }

  .lineup-card {
    grid-template-columns: 38px minmax(0, 1fr) auto;
    min-height: 68px;
    padding: 9px 12px;
    border-radius: 14px;
  }

  .lineup-card::before {
    width: 35px;
    height: 35px;
  }

  .item-copy strong {
    font-size: 15px;
  }

  .status {
    margin-inline: 4px;
  }

  .action-row {
    grid-template-columns: 1fr;
  }

  .secondary-button {
    grid-row: 2;
  }

  .summary {
    padding: 34px 20px;
  }

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

  .mode-card {
    min-height: 76px;
  }
}

@media (max-width: 1180px) {
  .ad-rail {
    display: none !important;
  }
}

@media (max-width: 380px) {
  .page-layout {
    padding-right: max(12px, env(safe-area-inset-right));
    padding-left: max(12px, env(safe-area-inset-left));
  }

  .logo {
    font-size: 18px;
  }

  .brand-group {
    gap: 8px;
  }

  .prompt h1 {
    font-size: 31px;
  }

  .round-meta {
    grid-template-columns: 70px minmax(78px, 1fr) 76px;
    gap: 8px;
  }

  .dialog-stats {
    grid-template-columns: 1fr;
  }
}
