* { box-sizing: border-box; }

/* An author `display` rule outranks the browser's own [hidden] rule, so
   every flex panel below would stay visible while hidden without this. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #0e0f15;
  color: #d7d9e0;
  font: 14px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  overflow: hidden;
}

#stage {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
}

#board {
  display: block;
  image-rendering: -webkit-optimize-contrast;
}

.fallback {
  padding: 24px;
  text-align: center;
}

#hud, #hud-balance {
  width: 128px;
  flex: 0 0 auto;
}

#hud {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.stat {
  display: flex;
  flex-direction: column;
  padding: 8px 10px;
  background: #15171f;
  border: 1px solid #2a2e42;
  border-radius: 6px;
}

.stat .label {
  font-size: 10px;
  letter-spacing: 0.1em;
  color: #7c829a;
}

.stat .value {
  font: 600 18px/1.2 ui-monospace, monospace;
  color: #eceef5;
}

#board-wrap {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

#popups {
  position: absolute;
  top: 18%;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  pointer-events: none;
}

.popup {
  font: 700 15px/1.2 ui-sans-serif, system-ui, sans-serif;
  letter-spacing: 0.06em;
  color: #fff;
  text-shadow: 0 0 10px rgba(140, 160, 255, 0.9);
  animation: popup 1.1s ease-out forwards;
}

@keyframes popup {
  0%   { opacity: 0; transform: translateY(8px) scale(0.9); }
  15%  { opacity: 1; transform: translateY(0) scale(1); }
  70%  { opacity: 1; }
  100% { opacity: 0; transform: translateY(-14px); }
}

.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 11, 16, 0.86);
  backdrop-filter: blur(3px);
  z-index: 10;
}

.panel {
  min-width: 300px;
  max-width: 92vw;
  max-height: 88vh;
  overflow-y: auto;
  padding: 24px 28px;
  background: #15171f;
  border: 1px solid #2a2e42;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: center;
}

.panel.wide { min-width: 420px; }

.panel h1 {
  margin: 0 0 6px;
  font-size: 34px;
  letter-spacing: 0.22em;
  color: #8ea0ff;
}

.panel h2 { margin: 0 0 6px; font-size: 20px; }

.panel button {
  padding: 10px 14px;
  font: 600 14px ui-sans-serif, system-ui, sans-serif;
  color: #eceef5;
  background: #222636;
  border: 1px solid #343a52;
  border-radius: 8px;
  cursor: pointer;
}

.panel button:hover { background: #2b3045; border-color: #4a5172; }

.bests {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 8px 0 0;
  font-size: 12px;
  color: #9aa1bb;
}

.hint { margin: 4px 0 0; font-size: 11px; color: #6f7694; }
.best-note { color: #51d88a; font-weight: 600; }

.handling {
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
  font-size: 12px;
}

.handling label { display: grid; grid-template-columns: 76px 1fr 44px; align-items: center; gap: 8px; }

.bindings {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 8px 0;
  text-align: left;
  font-size: 12px;
}

.binding { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.binding button { padding: 4px 10px; font-size: 12px; min-width: 120px; }

.guide-panel { width: min(880px, 94vw); text-align: left; }

.guide-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.guide-body { display: flex; gap: 16px; align-items: flex-start; }

.guide-list { display: flex; flex-direction: column; gap: 4px; width: 164px; flex: 0 0 auto; }
.guide-list button { text-align: left; font-size: 12px; padding: 7px 10px; }
.guide-list button.active { background: #333a55; border-color: #6b78ad; color: #fff; }

.guide-stage {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  min-height: min(460px, 46vh);
  display: flex;
  align-items: center;
  justify-content: center;
}

#guide-canvas { display: block; }

.guide-reference { font-size: 12px; line-height: 1.6; width: 100%; overflow-y: auto; }

.kick-intro { margin: 0 0 12px; color: #c4c9dc; }

.kick-pickers { display: flex; gap: 8px; margin-bottom: 14px; }
.kick-pickers select {
  padding: 6px 10px;
  font-size: 12px;
  color: #eceef5;
  background: #222636;
  border: 1px solid #343a52;
  border-radius: 6px;
}

/* The five candidate positions, left to right in the order they are tried. */
.kick-strip { display: flex; gap: 12px; flex-wrap: wrap; }

.kick-try {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px;
  background: #12141c;
  border: 1px solid #262b3d;
  border-radius: 8px;
}

.kick-try h4 {
  margin: 0;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #8ea0ff;
}

.kick-grid {
  display: grid;
  grid-template-columns: repeat(8, 11px);
  grid-auto-rows: 11px;
  gap: 1px;
}

.kick-cell { background: #1a1d28; border-radius: 1px; }
/* Where the turn would have landed with no kick at all. */
.kick-cell.nominal { box-shadow: inset 0 0 0 1px rgba(255, 217, 138, 0.8); }
.kick-cell.filled { border-radius: 1px; }

.kick-words { margin: 0; font-size: 11px; color: #9aa1bb; white-space: nowrap; }
.kick-note { margin: 14px 0 0; font-size: 11px; color: #6f7694; }

.guide-kick {
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  padding: 3px 8px;
  font: 600 11px ui-monospace, monospace;
  color: #ffd98a;
  background: rgba(10, 11, 16, 0.85);
  border-radius: 4px;
}

.guide-caption {
  margin: 12px 0 0;
  min-height: 3.2em;
  font-size: 13px;
  color: #c4c9dc;
}

.guide-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.guide-controls select {
  padding: 8px 10px;
  color: #eceef5;
  background: #222636;
  border: 1px solid #343a52;
  border-radius: 8px;
}
.guide-progress { margin-left: auto; font: 600 12px ui-monospace, monospace; color: #7c829a; }
