:root {
  --sky: #8eb6d9;
  --cream: #f4ead4;
  --ink: #3a2c24;
  --ink-soft: #6a5346;
  --leaf: #5c7a3a;
  --gold: #d4a24c;
  --rose: #d9897a;
  --veil: rgba(36, 28, 22, 0.38);
  --sheet: rgba(244, 234, 212, 0.94);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #1c2833;
  color: var(--ink);
  font-family: Georgia, "Palatino Linotype", Palatino, "Times New Roman", serif;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

#stage {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 520px;
  margin: 0 auto;
  overflow: hidden;
  background: #7aa4c8;
}

#world {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.screen,
.overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
}

.screen[hidden],
.overlay[hidden] {
  display: none;
}

#screen-skins,
#screen-board,
#screen-settings {
  background: rgba(36, 28, 22, 0.38);
}

#screen-menu {
  justify-content: flex-end;
  padding: calc(20px + var(--safe-t)) 22px calc(28px + var(--safe-b));
}

.title-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 40%;
  z-index: 0;
  pointer-events: none;
}

.menu-veil {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(
    180deg,
    rgba(28, 40, 51, 0.05) 20%,
    rgba(28, 40, 51, 0.15) 48%,
    rgba(36, 28, 22, 0.72) 100%
  );
  pointer-events: none;
}

.menu-hero,
.menu-actions {
  position: relative;
  z-index: 2;
}

.menu-hero {
  margin-bottom: 18px;
  color: var(--cream);
  text-shadow: 0 2px 12px rgba(30, 20, 12, 0.45);
}

.eyebrow {
  margin: 0 0 6px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 0.72rem;
  font-family: "Segoe UI", system-ui, sans-serif;
  opacity: 0.9;
}

h1 {
  margin: 0 0 8px;
  font-size: clamp(2.4rem, 10vw, 3.4rem);
  font-weight: 700;
  letter-spacing: 0.02em;
}

.tagline {
  margin: 0;
  max-width: 18em;
  color: #f7efe0;
  opacity: 0.92;
  line-height: 1.4;
}

.menu-actions {
  display: grid;
  gap: 10px;
}

.btn {
  appearance: none;
  border: 2px solid rgba(92, 122, 58, 0.35);
  background: var(--cream);
  color: var(--ink);
  border-radius: 999px;
  padding: 0.78rem 1.2rem;
  font: 700 1.05rem/1 Georgia, Palatino, serif;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(90, 68, 42, 0.18);
}

.btn:hover {
  filter: brightness(1.05);
}

.btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 rgba(90, 68, 42, 0.18);
}

.btn-primary {
  background: linear-gradient(180deg, #f3d27a, #d4a24c);
  border-color: #b8862f;
}

.btn-ghost {
  background: transparent;
  box-shadow: none;
  border-color: transparent;
  color: var(--leaf);
  padding: 0.4rem 0.6rem;
}

.sheet {
  margin: auto 18px;
  padding: 22px 20px 20px;
  width: calc(100% - 36px);
  max-height: calc(100% - 48px);
  overflow: auto;
  background: var(--sheet);
  background-image: url("assets/ui/panel.png");
  background-size: 100% 100%;
  border-radius: 22px;
  box-shadow: 0 16px 40px rgba(30, 22, 16, 0.28);
}

.sheet.compact {
  width: min(360px, calc(100% - 36px));
  text-align: center;
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

h2 {
  margin: 0;
  font-size: 1.6rem;
}

.sheet-lead,
.muted {
  color: var(--ink-soft);
  line-height: 1.4;
}

.row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid rgba(58, 44, 36, 0.08);
  font-size: 1.05rem;
}

.row input {
  width: 1.2rem;
  height: 1.2rem;
  accent-color: var(--leaf);
}

.diff-field {
  border: 0;
  padding: 14px 0 0;
  margin: 8px 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
}

.diff-field legend {
  font-weight: 700;
  padding: 0;
}

.skin-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.skin-card {
  border: 2px solid rgba(92, 122, 58, 0.28);
  background: rgba(255, 252, 245, 0.7);
  border-radius: 16px;
  padding: 10px 8px 12px;
  text-align: center;
  cursor: pointer;
  color: inherit;
  font: inherit;
}

.skin-card img {
  width: 100%;
  height: 92px;
  object-fit: contain;
}

.skin-card strong {
  display: block;
  margin-top: 4px;
}

.skin-card small {
  display: block;
  color: var(--ink-soft);
  font-family: "Segoe UI", system-ui, sans-serif;
}

.skin-card.selected {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(212, 162, 76, 0.35);
}

.skin-card.locked {
  opacity: 0.62;
  cursor: not-allowed;
}

.board-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
}

.board-list li {
  display: grid;
  grid-template-columns: 2rem 1fr auto;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(58, 44, 36, 0.08);
}

#screen-play {
  pointer-events: auto;
}

.hud {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: calc(12px + var(--safe-t)) 14px 0;
}

.hud-score {
  font-size: 3rem;
  color: #fff8ea;
  text-shadow: 0 3px 0 rgba(58, 44, 36, 0.35), 0 8px 16px rgba(30, 22, 16, 0.3);
  min-width: 3ch;
  text-align: center;
  line-height: 1;
}

.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 0;
  background: rgba(244, 234, 212, 0.88);
  color: var(--ink);
  font: 700 0.95rem/1 Georgia, serif;
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(90, 68, 42, 0.16);
}

.ready-hint {
  margin: auto 0 28%;
  text-align: center;
  color: #fff8ea;
  font-size: 1.15rem;
  text-shadow: 0 2px 8px rgba(30, 22, 16, 0.45);
}

.overlay {
  z-index: 5;
  background: var(--veil);
  align-items: center;
  justify-content: center;
}

.overlay .btn {
  width: 100%;
  margin-top: 8px;
}

.score-dl {
  display: flex;
  justify-content: center;
  gap: 28px;
  margin: 8px 0 12px;
}

.score-dl dt {
  font-size: 0.8rem;
  color: var(--ink-soft);
  font-family: "Segoe UI", system-ui, sans-serif;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.score-dl dd {
  margin: 0;
  font-size: 2rem;
}

.medal {
  width: 88px;
  height: 88px;
  object-fit: contain;
  margin: 8px auto 0;
  display: block;
}

.medal-label {
  margin: 4px 0 0;
  color: var(--leaf);
  font-weight: 700;
}

.install-url {
  margin: 8px 0 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 0.92rem;
  color: var(--leaf);
  word-break: break-all;
}

.install-steps {
  margin: 12px 0 16px;
  padding-left: 1.2rem;
  text-align: left;
  line-height: 1.5;
  color: var(--ink-soft);
}

.install-steps li {
  margin: 8px 0;
}

.name-pad .letters {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 10px 0;
}

.letter {
  width: 52px;
  height: 56px;
  border-radius: 12px;
  border: 2px solid rgba(92, 122, 58, 0.35);
  background: #fffdf6;
  font: 700 1.5rem/1 Georgia, serif;
  cursor: pointer;
}

@media (min-width: 720px) {
  #stage {
    height: min(100%, 920px);
    top: 50%;
    transform: translateY(-50%);
    border-radius: 28px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  }
}

@media (prefers-reduced-motion: reduce) {
  .btn:active {
    transform: none;
  }
}
