:root {
  color-scheme: light;
  font-family: Inter, ui-rounded, "SF Pro Rounded", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #cbc6bb;
  color: #292b2b;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  background:
    radial-gradient(circle at 14% -18%, rgba(255, 248, 233, .58), transparent 42%),
    radial-gradient(circle at 88% 112%, rgba(101, 119, 111, .14), transparent 46%),
    #cbc6bb;
  touch-action: none;
  user-select: none;
}

button { font: inherit; }

.game-shell {
  width: 100%;
  height: 100%;
  min-height: 300px;
  display: grid;
  grid-template-rows: auto 1fr;
  padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  gap: 9px;
}

.hud {
  min-height: 48px;
  display: grid;
  grid-template-columns: minmax(120px, 1fr) auto minmax(120px, 1fr);
  align-items: center;
  gap: 14px;
}

.title-block { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.title-block h1 { margin: 0; font-size: clamp(1.05rem, 2vw, 1.35rem); letter-spacing: -0.035em; font-weight: 720; }
.title-block p { margin: 0; color: #77736a; font-size: .76rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.progress {
  min-width: 72px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-size: .92rem;
  letter-spacing: .05em;
  color: #504e49;
}
.progress-divider { padding: 0 4px; color: #aaa397; }

.actions { display: flex; justify-content: flex-end; gap: 6px; }
button {
  min-height: 36px;
  padding: 7px 11px;
  border: 1px solid rgba(92, 87, 78, .28);
  border-radius: 999px;
  color: #454541;
  background: rgba(238, 234, 225, .58);
  cursor: pointer;
  transition: background .18s ease, transform .18s ease, border-color .18s ease;
}
button:hover { background: rgba(250,247,239,.82); border-color: #969086; }
button:active { transform: scale(.97); }
button:focus-visible { outline: 3px solid rgba(190, 104, 72, .28); outline-offset: 2px; }

.arena-wrap {
  position: relative;
  min-height: 0;
  overflow: hidden;
  border: 1px solid rgba(68, 65, 59, .27);
  border-radius: clamp(17px, 2.5vw, 28px);
  background: #d9d5ca;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.54),
    inset 0 0 48px rgba(73, 68, 59, .035),
    0 12px 36px rgba(52,47,41,.12);
}

#arena { display: block; width: 100%; height: 100%; }

.hint {
  position: absolute;
  left: 50%;
  bottom: 14px;
  translate: -50% 0;
  margin: 0;
  padding: 7px 11px;
  border-radius: 999px;
  background: rgba(224,220,210,.84);
  color: #77736a;
  font-size: .72rem;
  pointer-events: none;
  transition: opacity .55s ease, transform .55s ease;
}
.hint.is-hidden { opacity: 0; transform: translateY(6px); }

.joystick { display: none; position: absolute; left: 18px; bottom: 18px; width: 118px; height: 118px; touch-action: none; }
.joystick-ring { position: absolute; inset: 0; border: 1px solid rgba(74,72,66,.31); border-radius: 50%; background: rgba(218,214,204,.46); box-shadow: inset 0 0 0 8px rgba(255,255,255,.10), 0 5px 20px rgba(54,50,44,.08); }
.joystick-knob { position: absolute; width: 50px; height: 50px; left: 34px; top: 34px; border-radius: 50%; background: rgba(174,91,62,.8); box-shadow: 0 5px 16px rgba(91,57,44,.17); transform: translate(0,0); }

.complete-card {
  position: absolute;
  left: 50%; top: 50%;
  translate: -50% -50%;
  width: min(310px, calc(100% - 34px));
  padding: 24px;
  text-align: center;
  border: 1px solid rgba(77,72,63,.18);
  border-radius: 22px;
  background: rgba(232,228,218,.94);
  box-shadow: 0 20px 60px rgba(64,57,46,.16);
  backdrop-filter: blur(10px);
  animation: arrive .35s cubic-bezier(.2,.8,.2,1) both;
}
.complete-card[hidden] { display: none; }
.complete-card h2 { margin: 2px 0 18px; font-size: 1.65rem; letter-spacing: -.04em; }
.eyebrow { margin: 0; color: #8e897f; text-transform: uppercase; letter-spacing: .13em; font-size: .64rem; }
.complete-actions { display: flex; justify-content: center; gap: 8px; }
.complete-actions button:first-child { color: white; border-color: #a65e43; background: #b66b4e; }

.toast {
  position: absolute;
  right: 14px; bottom: 14px;
  padding: 8px 11px;
  border-radius: 10px;
  color: #f8f5ee;
  background: rgba(45,46,44,.88);
  font-size: .72rem;
  opacity: 0;
  transform: translateY(5px);
  pointer-events: none;
  transition: .2s ease;
}
.toast.is-visible { opacity: 1; transform: translateY(0); }

@keyframes arrive { from { opacity: 0; transform: translateY(8px) scale(.98); } }

@media (pointer: coarse) {
  .joystick { display: block; }
  .hint { left: 78px; bottom: 143px; translate: -50% 0; }
}

@media (max-width: 660px) {
  .game-shell { gap: 7px; padding-left: max(7px, env(safe-area-inset-left)); padding-right: max(7px, env(safe-area-inset-right)); }
  .hud { grid-template-columns: 1fr auto; gap: 6px 10px; }
  .title-block p { display: none; }
  .progress { justify-self: end; }
  .actions { grid-column: 1 / -1; justify-content: stretch; }
  .actions button { flex: 1; min-height: 34px; padding: 5px 8px; font-size: .78rem; }
}

@media (max-height: 470px) {
  .game-shell { padding-top: 6px; padding-bottom: 6px; gap: 5px; }
  .hud { min-height: 36px; grid-template-columns: auto 1fr auto; }
  .title-block p { display: none; }
  .actions { grid-column: auto; }
  .actions button { min-height: 31px; padding: 4px 9px; }
  .joystick { width: 96px; height: 96px; left: 12px; bottom: 12px; }
  .joystick-knob { width: 42px; height: 42px; left: 27px; top: 27px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
