:root {
  --bg: #fff8ec;
  --ink: #211f2d;
  --muted: #746f7d;
  --surface: #ffffff;
  --line: #e8dfd3;
  --coral: #ff6b5f;
  --teal: #20b8a5;
  --lemon: #ffd54d;
  --violet: #7867ff;
  --green: #4ec36f;
  --shadow: 0 18px 48px rgba(40, 30, 18, 0.13);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(255, 107, 95, 0.16), transparent 34%),
    linear-gradient(315deg, rgba(32, 184, 165, 0.18), transparent 42%),
    var(--bg);
}

button, input { font: inherit; }

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 300px;
  gap: 18px;
  min-height: 100vh;
  padding: 18px;
}

.library, .inspector, .stage-wrap {
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(232, 223, 211, 0.9);
  box-shadow: var(--shadow);
}

.library, .inspector {
  border-radius: 8px;
  padding: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: var(--ink);
  color: var(--lemon);
  font-weight: 900;
}

h1, h2, h3, p { margin: 0; }

h1 { font-size: 20px; line-height: 1.1; }
.brand p, .category, .score-grid span { color: var(--muted); font-size: 12px; font-weight: 700; }

.search-row {
  display: grid;
  grid-template-columns: 1fr 42px;
  gap: 8px;
  margin-bottom: 12px;
}

.library-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

input {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #fffdf8;
  color: var(--ink);
}

.icon-button, .ghost-button, .primary-button {
  min-height: 42px;
  border-radius: 8px;
  font-weight: 800;
}

.compact {
  min-height: 36px;
  padding: 0 12px;
  font-size: 13px;
}

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

.primary-button {
  background: var(--coral);
  color: white;
  box-shadow: 0 10px 20px rgba(255, 107, 95, 0.25);
}

.wide { width: 100%; }

.game-list {
  display: grid;
  gap: 8px;
  max-height: calc(100vh - 230px);
  overflow: auto;
  padding-right: 4px;
}

.site-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.site-links a {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
}

.game-item {
  display: grid;
  grid-template-columns: 38px 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  border-radius: 8px;
  padding: 8px;
  background: #fffdf8;
  border: 1px solid transparent;
  text-align: left;
  color: var(--ink);
}

.game-item.active {
  border-color: var(--ink);
  background: #fff3d7;
}

.game-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  color: white;
  font-weight: 900;
}

.game-name { font-size: 14px; font-weight: 850; line-height: 1.2; }
.game-type { font-size: 11px; color: var(--muted); margin-top: 3px; }
.best-chip { font-size: 11px; font-weight: 850; color: var(--teal); }

.play-area {
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 18px;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 78px;
}

.topbar h2 { font-size: 34px; line-height: 1.05; }
.top-actions { display: flex; gap: 10px; }

.stage-wrap {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 490px;
  border-radius: 8px;
  overflow: hidden;
}

.stage-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 46px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  background: #fffdf8;
}

.status-text { font-size: 13px; font-weight: 800; color: var(--muted); }
.mini-lamps { display: flex; gap: 6px; }
.mini-lamps span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--coral);
}
.mini-lamps span:nth-child(2) { background: var(--lemon); }
.mini-lamps span:nth-child(3) { background: var(--teal); }

.stage {
  position: relative;
  min-height: 444px;
  padding: 22px;
  outline: none;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(33, 31, 45, 0.04) 1px, transparent 1px),
    linear-gradient(rgba(33, 31, 45, 0.04) 1px, transparent 1px),
    #fffdf8;
  background-size: 28px 28px;
}

.inspector {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

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

.score-grid div {
  min-height: 76px;
  padding: 12px;
  border-radius: 8px;
  background: #fffdf8;
  border: 1px solid var(--line);
}

.score-grid strong {
  display: block;
  margin-top: 6px;
  font-size: 28px;
  line-height: 1;
}

.panel {
  padding: 14px;
  border-radius: 8px;
  background: #fffdf8;
  border: 1px solid var(--line);
}

.panel h3 { font-size: 14px; margin-bottom: 8px; }
.panel p { color: var(--muted); font-size: 13px; line-height: 1.65; }
.button-stack { margin-top: auto; display: grid; gap: 10px; }

.ad-slot {
  display: grid;
  place-items: center;
  gap: 2px;
  border: 1px dashed #dccfbd;
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.82);
  color: var(--muted);
  text-align: center;
}

.ad-slot span {
  color: var(--teal);
  font-size: 11px;
  font-weight: 900;
}

.ad-slot p {
  font-size: 12px;
  font-weight: 800;
}

.ad-slot-horizontal {
  min-height: 74px;
}

.ad-slot-rectangle {
  min-height: 112px;
}

.ad-slot ins {
  display: block;
  width: 100%;
  min-height: 72px;
}

.consent-banner {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  width: min(640px, calc(100vw - 36px));
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  box-shadow: var(--shadow);
}

.consent-banner p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.consent-banner div {
  display: flex;
  gap: 8px;
}

.center-screen {
  display: grid;
  place-items: center;
  min-height: 100%;
  text-align: center;
}

.big-target {
  width: min(270px, 68vw);
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--teal);
  color: white;
  font-size: 32px;
  font-weight: 950;
  box-shadow: 0 18px 0 #128777;
}

.grid {
  display: grid;
  gap: 10px;
  width: min(100%, 560px);
  margin: 0 auto;
}

.tile {
  display: grid;
  place-items: center;
  min-height: 64px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
  font-size: 22px;
  font-weight: 900;
  transition: transform 0.14s ease, background 0.14s ease;
}

.tile:active { transform: translateY(2px); }
.tile.good { background: #d9f8df; border-color: var(--green); }
.tile.bad { background: #ffe2de; border-color: var(--coral); }
.tile.dark { background: var(--ink); color: white; }
.tile.accent { background: var(--lemon); }

.choice-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.choice-row button, .text-input {
  min-height: 48px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: white;
  padding: 0 16px;
  color: var(--ink);
  font-weight: 850;
}

.text-input { width: min(420px, 100%); text-align: center; }

.prompt-card {
  width: min(620px, 100%);
  margin: 0 auto;
  padding: 22px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  text-align: center;
}

.prompt-card .prompt {
  margin: 12px 0 18px;
  font-size: clamp(28px, 7vw, 64px);
  font-weight: 950;
}

canvas {
  display: block;
  width: min(100%, 760px);
  height: min(62vh, 460px);
  min-height: 360px;
  margin: 0 auto;
  border-radius: 8px;
  background: #211f2d;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08);
}

.falling-word {
  position: absolute;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--ink);
  color: white;
  font-weight: 900;
}

.content-page {
  width: min(840px, calc(100% - 32px));
  margin: 40px auto;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.content-page h1 {
  margin: 14px 0 20px;
  font-size: 34px;
}

.content-page h2 {
  margin: 26px 0 8px;
  font-size: 20px;
}

.content-page p {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.8;
}

.content-page a {
  color: var(--teal);
  font-weight: 850;
}

.back-link {
  display: inline-block;
  color: var(--teal);
  font-size: 13px;
  font-weight: 900;
  text-decoration: none;
}

.updated {
  margin-top: 28px;
  font-size: 13px;
}

.contact-box {
  display: grid;
  gap: 6px;
  margin: 18px 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  cursor: pointer;
}

.contact-box span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.contact-box strong {
  font-size: 20px;
}

.seo-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  width: min(1180px, calc(100% - 36px));
  margin: 0 auto 24px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
}

.seo-section h2 {
  margin: 0 0 8px;
  font-size: 22px;
}

.seo-section p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

.primary-link,
.secondary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border-radius: 8px;
  padding: 0 16px;
  font-weight: 900;
  text-decoration: none;
}

.primary-link {
  background: var(--coral);
  color: #fff;
  box-shadow: 0 10px 20px rgba(255, 107, 95, 0.25);
}

.secondary-link {
  border: 1px solid var(--line);
  background: #fffdf8;
  color: var(--ink);
}

.detail-hero {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  gap: 18px;
  align-items: center;
  margin-top: 16px;
}

.detail-icon {
  display: grid;
  place-items: center;
  width: 84px;
  height: 84px;
  border-radius: 8px;
  background: var(--ink);
  color: var(--lemon);
  font-size: 36px;
  font-weight: 950;
}

.detail-label {
  color: var(--teal);
  font-size: 13px;
  font-weight: 900;
}

.detail-actions,
.detail-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 22px 0;
}

.detail-nav {
  justify-content: space-between;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.detail-nav a {
  text-decoration: none;
}

.game-link-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 22px;
}

.game-link-card {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 10px 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  color: var(--ink);
  text-decoration: none;
}

.game-link-card span {
  display: grid;
  place-items: center;
  grid-row: span 2;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--teal);
  color: #fff;
  font-weight: 950;
}

.game-link-card strong {
  font-size: 15px;
}

.game-link-card small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 240px 1fr;
  }
  .inspector { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr 1fr auto; align-items: start; }
  .ad-slot-rectangle { min-height: 76px; }
  .button-stack { margin-top: 0; min-width: 160px; }
}

@media (max-width: 760px) {
  .app-shell { grid-template-columns: 1fr; padding: 10px; }
  .library, .inspector { padding: 12px; }
  .game-list { grid-template-columns: repeat(2, minmax(0, 1fr)); max-height: 260px; }
  .game-item { grid-template-columns: 34px 1fr; }
  .best-chip { display: none; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .topbar h2 { font-size: 27px; }
  .top-actions { width: 100%; }
  .top-actions button { flex: 1; }
  .stage-wrap { min-height: 500px; }
  .stage { min-height: 454px; padding: 14px; }
  .inspector { display: flex; }
  .consent-banner { grid-template-columns: 1fr; }
  .consent-banner div { justify-content: stretch; }
  .consent-banner button { flex: 1; }
  canvas { min-height: 300px; }
  .content-page { margin: 16px auto; padding: 18px; }
  .content-page h1 { font-size: 28px; }
  .seo-section { align-items: stretch; flex-direction: column; }
  .game-link-grid { grid-template-columns: 1fr; }
  .detail-hero { grid-template-columns: 1fr; }
}
