:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #0b100c;
  color: #f1ead8;
  touch-action: none;
}

* { box-sizing: border-box; }

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

button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

#app {
  position: relative;
  width: 100vw;
  height: 100dvh;
  min-height: 100vh;
  overflow: hidden;
  isolation: isolate;
  background: #0b100c;
}

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

#hud {
  position: absolute;
  inset: max(14px, env(safe-area-inset-top)) max(64px, calc(env(safe-area-inset-right) + 14px)) auto max(14px, env(safe-area-inset-left));
  display: flex;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
}

.hud-card {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 10px 14px;
  border: 1px solid rgba(195, 181, 137, .22);
  border-radius: 14px;
  background: rgba(15, 23, 17, .78);
  box-shadow: 0 12px 36px rgba(0, 0, 0, .22);
  backdrop-filter: blur(12px);
  font-size: clamp(12px, 1vw, 15px);
  letter-spacing: .04em;
}

.health-card { width: clamp(220px, 23vw, 340px); }
.bar { flex: 1; height: 8px; overflow: hidden; border-radius: 999px; background: #354239; }
.bar i { display: block; width: 100%; height: 100%; background: linear-gradient(90deg, #9c443d, #d8bd78); transition: width .15s; }
.stats-card { flex-wrap: wrap; justify-content: flex-end; }
.stats-card b { color: #e0ca8e; font-variant-numeric: tabular-nums; }
.debug-stat { display: none; }

.icon-button {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));
  z-index: 3;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid rgba(195, 181, 137, .28);
  border-radius: 13px;
  background: rgba(15, 23, 17, .84);
  color: #eee5d0;
  cursor: pointer;
}

.fullscreen-button { top: auto; bottom: max(14px, env(safe-area-inset-bottom)); }

#overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 24px;
  visibility: hidden;
  opacity: 0;
  background: radial-gradient(circle at 50% 25%, rgba(76, 112, 82, .3), rgba(8, 13, 9, .91) 62%);
  transition: opacity .2s, visibility .2s;
}

#overlay.visible { visibility: visible; opacity: 1; }

.menu-card {
  width: min(460px, 100%);
  padding: clamp(24px, 5vw, 44px);
  text-align: center;
  border: 1px solid rgba(216, 199, 148, .24);
  border-radius: 28px;
  background: linear-gradient(145deg, rgba(18, 28, 20, .97), rgba(40, 47, 31, .95));
  box-shadow: 0 30px 90px rgba(0, 0, 0, .48);
}

#eyebrow { margin: 0 0 10px; color: #9fc2a5; font-size: 11px; font-weight: 800; letter-spacing: .2em; }
h1 { margin: 0; font-size: clamp(34px, 7vw, 54px); letter-spacing: -.04em; }
#message { min-height: 48px; margin: 16px 0 24px; color: #cbc6b7; line-height: 1.6; }
#result { margin: -8px 0 20px; color: #dfc987; font-weight: 700; }

.primary {
  width: 100%;
  min-height: 52px;
  border: 0;
  border-radius: 15px;
  background: linear-gradient(135deg, #8fb899, #d0b66f);
  color: #101711;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 14px 36px rgba(143, 184, 153, .22);
}

.options { display: flex; justify-content: center; gap: 24px; margin: 20px 0 14px; color: #cbc6b7; font-size: 14px; }
.options label { cursor: pointer; }
.options input { accent-color: #8fb899; }
.text-button { border: 0; background: transparent; color: #9fc2a5; cursor: pointer; }
.controls { display: block; margin-top: 16px; color: #778277; line-height: 1.6; }

#touchControls { position: absolute; inset: 0; z-index: 4; display: none; pointer-events: none; }
#app.show-touch #touchControls { display: block; }
.move-zone { position: absolute; left: max(18px, env(safe-area-inset-left)); bottom: max(18px, env(safe-area-inset-bottom)); width: 142px; height: 142px; pointer-events: auto; }
.joystick { position: absolute; inset: 20px; border: 1px solid rgba(216, 199, 148, .22); border-radius: 50%; background: rgba(15, 23, 17, .48); }
.joystick i { position: absolute; left: 50%; top: 50%; width: 48px; height: 48px; margin: -24px; border-radius: 50%; background: rgba(143, 184, 153, .72); box-shadow: 0 0 26px rgba(143, 184, 153, .3); }
.touch-actions { position: absolute; right: max(22px, env(safe-area-inset-right)); bottom: max(24px, env(safe-area-inset-bottom)); display: flex; align-items: flex-end; gap: 16px; pointer-events: auto; }
.touch-actions button { width: 60px; height: 60px; border: 1px solid rgba(238, 226, 191, .28); border-radius: 50%; background: rgba(83, 70, 45, .72); color: #f2ead3; font-weight: 900; }
.touch-actions .attack { width: 82px; height: 82px; background: rgba(65, 105, 77, .78); }

#orientationNotice { position: absolute; inset: 0; z-index: 30; display: none; place-items: center; padding: 24px; background: #0b100c; text-align: center; }
#orientationNotice div { display: grid; gap: 8px; }
#orientationNotice strong { font-size: 24px; }
#orientationNotice small { color: #8b9488; }
#app.portrait #orientationNotice { display: grid; }

@media (pointer: coarse) { #touchControls { display: block; } }
@media (max-width: 700px) {
  #hud { right: 58px; }
  .hud-card { padding: 8px 10px; font-size: 11px; }
  .health-card { width: 32vw; }
  .stats-card span:nth-child(4) { display: none; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition-duration: .01ms !important; } }
