:root {
  --bg: #0c1210;
  --moss: #4a7c59;
  --bone: #e8e0d0;
  --blood: #c43c3c;
  --gold: #d4a84b;
  --night: #1a2438;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--bone);
  font-family: "Nunito", system-ui, sans-serif;
  overflow: hidden;
  touch-action: none;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  height: 100dvh;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  background: #1a2a1c;
  cursor: crosshair;
}

#hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: linear-gradient(180deg, rgba(0,0,0,0.65), transparent);
  pointer-events: none;
  flex-wrap: wrap;
}

#hud button { pointer-events: auto; }

.hud-left, .hud-mid, .hud-right {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.9rem;
  font-weight: 800;
}

#phase {
  font-family: "Creepster", cursive;
  font-size: 1.4rem;
  letter-spacing: 0.04em;
  color: var(--gold);
}

.mute {
  font: inherit;
  font-weight: 800;
  border: 1px solid rgba(232, 224, 208, 0.3);
  background: rgba(0,0,0,0.4);
  color: var(--bone);
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
}

.pad {
  position: absolute;
  left: 18px;
  bottom: 18px;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  border: 2px solid rgba(255,255,255,0.15);
  z-index: 6;
  touch-action: none;
}

.stick {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 46px;
  height: 46px;
  margin: -23px 0 0 -23px;
  border-radius: 50%;
  background: rgba(212, 168, 75, 0.85);
  pointer-events: none;
}

.btn-act {
  position: absolute;
  right: 18px;
  bottom: 28px;
  z-index: 6;
  width: 84px;
  height: 84px;
  border-radius: 50%;
  border: 3px solid rgba(232, 224, 208, 0.4);
  background: rgba(74, 124, 89, 0.9);
  color: #fff;
  font-family: inherit;
  font-weight: 800;
  font-size: 0.78rem;
  cursor: pointer;
  touch-action: none;
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 16px;
  background:
    radial-gradient(ellipse 70% 50% at 50% 20%, rgba(74, 124, 89, 0.25), transparent 60%),
    rgba(8, 12, 10, 0.92);
  overflow: auto;
}

.overlay.hidden { display: none; }

.panel {
  width: min(440px, 100%);
  background: linear-gradient(165deg, #1a241c, #101612);
  border: 1px solid rgba(212, 168, 75, 0.35);
  border-radius: 20px;
  padding: 22px 18px;
  box-shadow: 0 24px 50px rgba(0,0,0,0.5);
}

.eyebrow {
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 800;
}

h1 {
  font-family: "Creepster", cursive;
  font-size: clamp(2.4rem, 10vw, 3.4rem);
  color: #e8e0d0;
  font-weight: 400;
  margin: 4px 0 10px;
  letter-spacing: 0.02em;
}

h2 {
  font-family: "Creepster", cursive;
  font-size: 2rem;
  margin-bottom: 8px;
  color: var(--blood);
}

.tag, .rules, .controls, .stats {
  line-height: 1.45;
  color: rgba(232, 224, 208, 0.85);
  margin-bottom: 12px;
}

.rules {
  list-style: none;
  display: grid;
  gap: 6px;
  font-size: 0.9rem;
}

.rules li {
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255,255,255,0.04);
}

.controls {
  font-size: 0.8rem;
  opacity: 0.7;
}

.primary {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 14px;
  border: none;
  border-radius: 14px;
  font: inherit;
  font-weight: 800;
  font-size: 1.05rem;
  cursor: pointer;
  background: linear-gradient(180deg, #6a9a6a, #3d6b4a);
  color: #fff;
  box-shadow: 0 8px 20px rgba(74, 124, 89, 0.35);
}

.back-line {
  text-align: center;
  margin-top: 14px;
}

.back-line a {
  color: var(--gold);
  font-weight: 800;
  text-decoration: none;
}

.best-line {
  text-align: center;
  margin-top: 12px;
  font-weight: 800;
  color: var(--gold);
  font-size: 0.95rem;
}

.board-inline {
  margin-top: 14px;
  padding: 12px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(212, 168, 75, 0.2);
}

.board-inline h3,
#board h3 {
  font-family: "Nunito", sans-serif;
  font-size: 0.75rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 10px;
}

#board-list,
#board-list-inline,
#board-list-go {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#board-list li,
#board-list-inline li,
#board-list-go li {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 7px 9px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  font-variant-numeric: tabular-nums;
  font-size: 0.88rem;
}

#board-list .rank,
#board-list-inline .rank,
#board-list-go .rank {
  color: rgba(232, 224, 208, 0.45);
  font-weight: 800;
}

#board-list .name,
#board-list-inline .name,
#board-list-go .name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

#board-list .pts,
#board-list-inline .pts,
#board-list-go .pts {
  color: #6ecf7a;
  font-weight: 800;
}

#board-list li.top1,
#board-list-inline li.top1,
#board-list-go li.top1 {
  border-color: rgba(212, 168, 75, 0.45);
}

.board-empty {
  color: rgba(232, 224, 208, 0.5);
  font-size: 0.85rem;
}

.board-empty[hidden],
#board-list:not(:empty) + .board-empty,
#board-list-inline:not(:empty) + .board-empty,
#board-list-go:not(:empty) + .board-empty {
  display: none;
}

.save-box {
  margin: 12px 0;
  display: grid;
  gap: 8px;
}

.save-box label {
  font-size: 0.8rem;
  font-weight: 800;
  color: rgba(232, 224, 208, 0.75);
}

.save-box input {
  font: inherit;
  font-weight: 700;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(212, 168, 75, 0.35);
  background: rgba(0, 0, 0, 0.35);
  color: var(--bone);
}

.save-box input:focus {
  outline: 2px solid rgba(212, 168, 75, 0.45);
}

#save {
  font: inherit;
  font-weight: 800;
  padding: 11px;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  background: linear-gradient(180deg, #d4a84b, #a87828);
  color: #1a1408;
}

#save:disabled {
  opacity: 0.5;
  cursor: default;
}

.save-msg {
  font-size: 0.85rem;
  font-weight: 700;
  color: #6ecf7a;
}

#board {
  position: absolute;
  top: 70px;
  right: 14px;
  z-index: 8;
  width: 220px;
  padding: 12px;
  border-radius: 14px;
  background: rgba(10, 14, 12, 0.82);
  border: 1px solid rgba(212, 168, 75, 0.28);
  pointer-events: none;
  max-height: min(420px, calc(100vh - 100px));
  overflow: auto;
}

#board[hidden] {
  display: none !important;
}

#toast {
  position: absolute;
  left: 50%;
  bottom: 120px;
  transform: translateX(-50%);
  z-index: 15;
  background: rgba(0,0,0,0.8);
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(212,168,75,0.4);
  font-weight: 800;
  white-space: nowrap;
  max-width: 90vw;
  overflow: hidden;
  text-overflow: ellipsis;
}

#toast[hidden] { display: none; }

@media (max-width: 900px) {
  #board {
    display: none !important;
  }
}

@media (min-width: 900px) {
  .pad, .btn-act { display: none !important; }
}
