:root {
  --ink: #1a1208;
  --paper: #f3e6c8;
  --amber: #e8a317;
  --rust: #c45c26;
  --teal: #1f6f6a;
  --truck: #2d5a27;
  --sky1: #f0c27b;
  --sky2: #4a3728;
  --safe: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  touch-action: none;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--ink);
  color: var(--paper);
  font-family: "Zen Maru Gothic", system-ui, sans-serif;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 480px;
  margin: 0 auto;
  background:
    radial-gradient(120% 80% at 50% -10%, #ffd78a 0%, transparent 55%),
    linear-gradient(180deg, #c9783a 0%, #5c3a28 42%, #24180f 100%);
  overflow: hidden;
}

#game.playable {
  cursor: grab;
}

#game.grabbing {
  cursor: grabbing;
}

.pc-tip {
  display: none;
  margin: 12px 0 0;
  font-size: 0.82rem;
  color: rgba(243, 230, 200, 0.65);
}

#app::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(
    -18deg,
    transparent 0 14px,
    rgba(255, 255, 255, 0.03) 14px 15px
  );
  pointer-events: none;
  z-index: 1;
}

.top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: max(12px, env(safe-area-inset-top)) 16px 8px;
  pointer-events: none;
}

.brand {
  font-family: Bungee, cursive;
  font-size: 1.05rem;
  letter-spacing: 0.04em;
  color: var(--ink);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
}

.stats {
  font-weight: 900;
  font-size: 1.15rem;
  color: var(--ink);
  background: rgba(243, 230, 200, 0.88);
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 4px 12px;
}

.stats .sep {
  opacity: 0.45;
  margin: 0 2px;
}

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  display: block;
}

.hud {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(18px + var(--safe));
  z-index: 5;
  text-align: center;
  pointer-events: none;
}

.hint {
  margin: 0 auto;
  display: inline-block;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(26, 18, 8, 0.88);
  border: 1px solid rgba(255, 243, 214, 0.55);
  color: #fff8e8;
  font-weight: 700;
  font-size: 0.92rem;
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: end center;
  padding: 24px 18px calc(28px + var(--safe));
  background:
    linear-gradient(180deg, rgba(26, 18, 8, 0.15) 0%, rgba(26, 18, 8, 0.78) 55%, rgba(26, 18, 8, 0.92) 100%);
}

.overlay.hidden {
  display: none;
}

.panel {
  width: min(100%, 380px);
  text-align: left;
  animation: rise 0.45s cubic-bezier(0.2, 0.9, 0.2, 1) both;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(28px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--amber);
  font-weight: 700;
}

h1 {
  margin: 0 0 12px;
  font-family: Bungee, cursive;
  font-size: clamp(2rem, 9vw, 2.7rem);
  line-height: 1.05;
  color: var(--paper);
}

h1 span {
  color: var(--amber);
}

h2 {
  margin: 0 0 8px;
  font-family: Bungee, cursive;
  font-size: 1.6rem;
}

.lead,
.flavor {
  margin: 0 0 18px;
  font-size: 1rem;
  line-height: 1.55;
  color: #fff3d6;
}

.big-score {
  margin: 0 0 10px;
  font-family: Bungee, cursive;
  font-size: 3rem;
  color: var(--amber);
  line-height: 1;
}

.big-score small {
  font-family: "Zen Maru Gothic", sans-serif;
  font-size: 1rem;
  font-weight: 700;
  color: var(--paper);
}

.row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn {
  appearance: none;
  border: 2px solid var(--ink);
  border-radius: 14px;
  padding: 14px 18px;
  font-family: inherit;
  font-weight: 900;
  font-size: 1.05rem;
  cursor: pointer;
  touch-action: manipulation;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn.primary {
  background: var(--amber);
  color: var(--ink);
  box-shadow: 0 6px 0 #8a5a0c;
}

.btn.primary:active {
  transform: translateY(3px);
  box-shadow: 0 3px 0 #8a5a0c;
}

.btn.ghost {
  background: rgba(26, 18, 8, 0.45);
  color: #fff8e8;
  border-color: rgba(255, 243, 214, 0.75);
}

.btn.ghost:hover {
  background: rgba(26, 18, 8, 0.7);
  color: #fff;
}

@media (min-width: 481px) {
  #app {
    max-width: min(720px, 100vw);
    border-left: 1px solid rgba(255, 255, 255, 0.08);
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25), 0 24px 80px rgba(0, 0, 0, 0.45);
  }

  .pc-tip {
    display: block;
  }

  .panel {
    width: min(100%, 420px);
  }
}

@media (min-width: 900px) and (pointer: fine) {
  #app {
    max-width: min(820px, 92vw);
    max-height: min(100vh, 920px);
    height: min(100vh, 920px);
    margin-top: max(0px, calc((100vh - min(100vh, 920px)) / 2));
    border-radius: 12px;
  }
}

/* Phone keeps full-bleed; don't force desktop chrome */
@media (pointer: coarse) {
  .pc-tip {
    display: none !important;
  }

  #app {
    max-width: 480px;
    border-radius: 0;
    margin-top: 0;
    height: 100%;
    max-height: none;
  }
}
