:root {
  color-scheme: light;
  --bg-top: #80e3ff;
  --bg-mid: #baf4b2;
  --ink: #173624;
  --muted: rgba(23, 54, 36, 0.72);
  --panel: rgba(255, 248, 231, 0.92);
  --panel-strong: rgba(255, 251, 241, 0.96);
  --line: rgba(31, 68, 44, 0.12);
  --accent: #ffc94b;
  --accent-deep: #d87b11;
  --shadow: rgba(17, 44, 28, 0.16);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top right, rgba(255, 223, 108, 0.32), transparent 18%),
    linear-gradient(180deg, var(--bg-top), var(--bg-mid));
  color: var(--ink);
  font-family: "Avenir Next", Avenir, "Trebuchet MS", "Segoe UI", sans-serif;
}

body.is-embedded {
  min-height: auto;
}

button {
  font: inherit;
}

.dash-shell {
  width: min(1280px, calc(100vw - 1.5rem));
  margin: 0 auto;
  padding: 1rem 0 1.25rem;
}

body.is-embedded .dash-shell {
  width: min(1220px, 100vw);
  padding-top: 0.5rem;
}

body.is-embedded .hud-row {
  margin-top: 0.25rem;
}

.dash-header,
.dash-layout,
.stat-card,
.hud-pill,
.canvas-shell,
.touch-controls {
  border-radius: 28px;
}

.dash-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.1rem;
  margin-bottom: 0.85rem;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 18px 36px var(--shadow);
}

body.is-embedded .dash-header {
  display: none;
}

.title-block h1 {
  margin: 0;
  font-size: clamp(2rem, 3vw, 2.8rem);
  line-height: 0.95;
}

.subtitle {
  margin: 0.45rem 0 0;
  color: var(--muted);
  font-size: 1.02rem;
  font-weight: 700;
}

.small-kicker {
  margin: 0 0 0.45rem;
  color: #d05d4d;
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  justify-content: flex-end;
}

.toolbar-btn,
.touch-btn,
.big-btn,
.ghost-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 52px;
  border: 0;
  border-radius: 999px;
  padding: 0.9rem 1.15rem;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.toolbar-icon {
  font-size: 1.05rem;
  line-height: 1;
}

.toolbar-btn,
.ghost-btn {
  background: rgba(255, 252, 246, 0.94);
  color: var(--ink);
  box-shadow: 0 10px 20px rgba(18, 44, 28, 0.08);
}

.big-btn,
.touch-btn {
  background: linear-gradient(180deg, #ffd96f, #f1a63c);
  color: #3f2606;
  font-weight: 900;
  box-shadow: 0 14px 24px rgba(155, 93, 21, 0.22);
}

.toolbar-btn:hover,
.touch-btn:hover,
.big-btn:hover,
.ghost-btn:hover {
  transform: translateY(-1px);
}

.dash-layout {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  gap: 0.9rem;
}

body.is-embedded .dash-layout {
  grid-template-columns: 1fr;
}

.dash-sidebar {
  display: grid;
  gap: 0.8rem;
}

body.is-embedded .dash-sidebar {
  display: none;
}

.stat-card {
  padding: 1rem;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  box-shadow: 0 18px 36px rgba(18, 44, 28, 0.1);
}

.score-value {
  margin: 0;
  font-size: clamp(2rem, 5vw, 2.7rem);
  font-weight: 900;
  line-height: 1;
}

.meter {
  overflow: hidden;
  height: 20px;
  border-radius: 999px;
  background: rgba(23, 54, 36, 0.1);
}

.meter span {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #ffc84b, #ff9640);
  border-radius: inherit;
  transition: width 160ms ease;
}

.stat-copy {
  margin: 0.55rem 0 0;
  color: var(--muted);
  line-height: 1.45;
  font-weight: 700;
}

.dash-stage {
  display: grid;
  gap: 0.75rem;
}

.hud-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.6rem;
}

.hud-pill {
  display: grid;
  gap: 0.3rem;
  align-content: center;
  min-height: 76px;
  padding: 0.8rem 1rem;
  background: rgba(255, 251, 241, 0.96);
  border: 1px solid var(--line);
  box-shadow: 0 14px 26px rgba(18, 44, 28, 0.08);
}

.hud-pill span {
  color: #cc6247;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.hud-pill strong {
  font-size: clamp(1.15rem, 2vw, 1.5rem);
}

.hud-pill--mode strong {
  color: #19553a;
}

.canvas-shell {
  position: relative;
  overflow: hidden;
  padding: 0.9rem;
  background:
    linear-gradient(180deg, rgba(255, 252, 243, 0.94), rgba(241, 232, 199, 0.9));
  border: 1px solid rgba(29, 60, 43, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75), 0 24px 44px rgba(18, 44, 28, 0.12);
}

.embedded-toolbar {
  position: absolute;
  top: 1.2rem;
  right: 1.25rem;
  z-index: 3;
  display: none;
  gap: 0.55rem;
}

.toolbar-btn--embedded {
  min-height: 46px;
  padding: 0.72rem 1rem;
  background: rgba(255, 250, 239, 0.92);
  box-shadow: 0 12px 24px rgba(18, 44, 28, 0.12);
}

body.is-embedded .embedded-toolbar {
  display: flex;
}

body.is-embedded .canvas-shell {
  padding-top: 4.8rem;
  border-radius: 32px;
  background:
    radial-gradient(circle at top right, rgba(255, 229, 137, 0.34), transparent 24%),
    linear-gradient(180deg, rgba(255, 248, 227, 0.98), rgba(239, 230, 193, 0.94));
}

#game-canvas {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 22px;
  background: linear-gradient(180deg, #77defc, #afe9a6 58%, #2e7e3f 58%, #1b542b 100%);
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: rgba(18, 41, 28, 0.26);
}

.overlay.is-hidden {
  display: none;
}

.overlay-card {
  width: min(540px, 100%);
  padding: 1.35rem;
  border-radius: 28px;
  background: rgba(255, 249, 234, 0.96);
  border: 1px solid rgba(32, 58, 39, 0.1);
  box-shadow: 0 26px 50px rgba(16, 36, 23, 0.18);
}

.overlay-card h2 {
  margin: 0 0 0.55rem;
  font-size: clamp(1.8rem, 4vw, 2.45rem);
  line-height: 0.98;
}

.overlay-card p {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
  line-height: 1.5;
}

.overlay-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin-top: 1rem;
}

.touch-controls {
  display: flex;
  gap: 0.7rem;
  justify-content: center;
  padding: 0.1rem;
}

.touch-btn {
  flex: 1 1 0;
  max-width: 280px;
}

.touch-btn--slide {
  background: linear-gradient(180deg, #fff5d0, #f6c56e);
}

@media (max-width: 920px) {
  .dash-shell {
    width: min(100vw, calc(100vw - 0.75rem));
    padding-top: 0.4rem;
  }

  .dash-layout {
    grid-template-columns: 1fr;
  }

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

  .hud-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .dash-shell {
    width: 100vw;
    padding: 0;
  }

  .dash-header,
  .canvas-shell,
  .stat-card,
  .hud-pill {
    border-radius: 22px;
  }

  .dash-header {
    margin: 0.4rem;
  }

  .dash-layout {
    gap: 0.5rem;
    padding: 0 0.4rem 0.8rem;
  }

  .dash-sidebar {
    grid-template-columns: 1fr;
  }

  .header-actions {
    width: 100%;
    justify-content: stretch;
  }

  .header-actions .toolbar-btn {
    flex: 1 1 0;
  }

  .overlay {
    padding: 0.85rem;
  }

  .embedded-toolbar {
    top: 0.85rem;
    left: 0.85rem;
    right: 0.85rem;
    flex-wrap: wrap;
  }

  .embedded-toolbar .toolbar-btn {
    flex: 1 1 0;
  }

  .overlay-card {
    padding: 1rem;
  }
}
