:root {
  --bg: #05050c;
  --felt: #0c4526;
  --ink: #e8e6df;
  --dim: #9a978c;
  --accent: #e8c15a;
  --danger: #e05a4e;
  --panel: #101019;
  --line: #23233a;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  overscroll-behavior: none;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

#app { height: 100%; display: flex; flex-direction: column; }

button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }

/* ------------------------------------------------------------------ menu */

.menu {
  margin: auto;
  text-align: center;
  padding: 24px;
  max-width: 420px;
  width: 100%;
}
.menu h1 {
  font-size: clamp(56px, 14vw, 88px);
  letter-spacing: -0.03em;
  color: var(--ink);
}
.menu h1 span { color: var(--accent); }
.menu-sub { color: var(--dim); margin: 4px 0 32px; }
.menu-buttons { display: flex; flex-direction: column; gap: 12px; }
.menu-buttons button {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 20px;
  font-size: 18px;
  font-weight: 600;
  text-align: left;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  transition: border-color 0.15s, transform 0.1s;
}
.menu-buttons button small { color: var(--dim); font-weight: 400; font-size: 13px; }
.menu-buttons button.ready:hover { border-color: var(--accent); transform: translateY(-1px); }
.menu-buttons button:disabled { opacity: 0.45; cursor: default; }
.menu-sublist { display: flex; gap: 8px; }
.menu-sublist.hidden { display: none; }
.menu-sublist button {
  flex: 1;
  padding: 10px 8px;
  font-size: 14px;
  justify-content: center;
  background: #161624;
}
.menu-sublist button:hover { border-color: var(--accent); }
.menu-foot { margin-top: 36px; }
.menu-foot a { color: var(--dim); text-decoration: none; }
.menu-foot a:hover { color: var(--accent); }

.menu-name {
  width: 100%;
  margin-bottom: 14px;
  padding: 10px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  font: inherit;
  text-align: center;
}
.menu-name:focus { outline: none; border-color: var(--accent); }
.menu-chip {
  margin-bottom: 14px;
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--dim);
  font-size: 13px;
}
.menu-chip:not(:disabled):hover { border-color: var(--accent); color: var(--accent); }
.menu-chip:disabled { color: var(--accent); cursor: default; }

/* ----------------------------------------------------------------- lobby */

.lobby {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5,5,12,0.65);
  z-index: 8;
}
.lobby.hidden { display: none; }
.lobby-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 26px;
  max-width: 420px;
  width: calc(100% - 32px);
  text-align: center;
  box-shadow: 0 18px 60px rgba(0,0,0,0.6);
}
.lobby-card h2 { margin-bottom: 6px; }
.lobby-sub { color: var(--dim); font-size: 14px; margin-bottom: 16px; }
.lobby-link-row { display: flex; gap: 8px; }
.lobby-link {
  flex: 1;
  min-width: 0;
  padding: 10px;
  background: #08080f;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--accent);
  font-size: 13px;
}
.lobby-copy {
  padding: 10px 16px;
  background: var(--accent);
  color: #14100a;
  font-weight: 700;
  border-radius: 8px;
}
.lobby-copy:hover { filter: brightness(1.1); }
.lobby-share { margin-top: 10px; }
.lobby-who { margin-top: 16px; color: var(--dim); font-size: 14px; }

/* ------------------------------------------------------------------ game */

.game-screen { position: relative; flex: 1; display: flex; min-height: 0; }
.table-canvas { flex: 1; width: 100%; height: 100%; display: block; touch-action: none; }

.hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: linear-gradient(rgba(5,5,12,0.85), transparent);
  z-index: 5;
  pointer-events: none;
}
.hud button { pointer-events: auto; }
.hud-back { color: var(--dim); font-weight: 600; }
.hud-back:hover { color: var(--ink); }
.hud-status { flex: 1; text-align: center; color: var(--dim); font-size: 14px; }
.hud-action {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 13px;
}
.hud-action:hover { border-color: var(--accent); }

/* ---------------------------------------------------------------- power */

.power-track {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 46px;
  height: min(46vh, 340px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  z-index: 6;
  touch-action: none;
  overflow: hidden;
}
.power-fill {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 0%;
  background: linear-gradient(#4caf6e, #e8c15a 70%, #e05a4e);
  opacity: 0.85;
  transition: none;
}
.power-track.hot { box-shadow: 0 0 14px rgba(224,90,78,0.6); }
.power-knob {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--ink);
  text-shadow: 0 1px 3px #000;
}

/* ---------------------------------------------------------------- rules */

.rules-modal {
  position: fixed;
  inset: 0;
  background: rgba(5,5,12,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}
.rules-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px;
  width: min(400px, calc(100% - 32px));
  box-shadow: 0 18px 60px rgba(0,0,0,0.6);
}
.rules-card h2 { margin-bottom: 14px; text-align: center; }
.rules-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 14px;
  color: var(--ink);
}
.rules-presets { justify-content: stretch; }
.rules-presets button {
  flex: 1;
  padding: 8px;
  background: #161624;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-weight: 600;
}
.rules-presets button.sel { border-color: var(--accent); color: var(--accent); }
.rules-row select {
  background: #08080f;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
  font: inherit;
}
.rules-check { justify-content: flex-start; }
.rules-check input { accent-color: var(--accent); }
.rules-actions { display: flex; gap: 10px; margin-top: 16px; }
.rules-actions button {
  flex: 1;
  padding: 12px;
  border-radius: 10px;
  font-weight: 700;
}
.rules-cancel { background: #161624; border: 1px solid var(--line); }
.rules-ok { background: var(--accent); color: #14100a; }

/* --------------------------------------------------------------- browser */

.browser {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: 560px;
  width: 100%;
  margin: 0 auto;
  padding: 16px;
  gap: 12px;
}
.browser-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.browser-head h2 { font-size: 20px; }
.browser-actions { display: flex; gap: 10px; }
.browser-actions button {
  flex: 1;
  padding: 14px;
  border-radius: 12px;
  font-weight: 700;
  background: var(--panel);
  border: 1px solid var(--line);
}
.browser-quick { background: var(--accent) !important; color: #14100a; border: none !important; }
.browser-actions button:hover { border-color: var(--accent); }
.browser-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.browser-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
}
.browser-info { display: flex; flex-direction: column; gap: 2px; }
.browser-info small { color: var(--dim); }
.browser-row button {
  padding: 8px 18px;
  background: #161624;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-weight: 600;
}
.browser-row button:hover { border-color: var(--accent); }
.browser-empty { color: var(--dim); text-align: center; margin-top: 30px; }

/* ----------------------------------------------------------------- spin */

.spin-btn {
  position: absolute;
  left: 12px;
  bottom: 12px;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 32%, #fff, #cfccc2 70%, #8f8d84);
  border: 2px solid var(--line);
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
}
.spin-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--danger);
  display: block;
}
.spin-modal {
  position: absolute;
  inset: 0;
  background: rgba(5,5,12,0.72);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  z-index: 10;
}
.spin-modal.hidden { display: none; }
.spin-face {
  width: 170px;
  height: 170px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 32%, #fff, #d8d5cb 65%, #97948a);
  position: relative;
  touch-action: none;
  box-shadow: 0 12px 40px rgba(0,0,0,0.6);
}
.spin-cross {
  position: absolute;
  inset: 0;
}
.spin-cross::before, .spin-cross::after {
  content: '';
  position: absolute;
  background: rgba(0,0,0,0.15);
}
.spin-cross::before { left: 50%; top: 8%; bottom: 8%; width: 1px; }
.spin-cross::after { top: 50%; left: 8%; right: 8%; height: 1px; }
.spin-dot.big {
  width: 18px;
  height: 18px;
  position: absolute;
  left: calc(50% - 9px);
  top: calc(50% - 9px);
}
.spin-hint { color: var(--dim); font-size: 13px; max-width: 260px; text-align: center; }
