/* Styles for the Wordweavers typing drill (Phase 1).
 * In Phase 2 this overlay floats above the Phaser canvas; the class names
 * and structure already match that future, so only positioning changes.
 */

:root {
  --bg: #1c1b2e;            /* deep night sky */
  --panel: #2a2843;
  --text: #e8e6f0;
  --gold: #e8c45a;
  --pending: #6f6c8a;       /* untyped characters */
  --correct: #6fd08c;       /* typed right */
  --error: #e0566b;         /* typed wrong — backspace to fix */
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  color: var(--text);
  font-family: Georgia, "Times New Roman", serif;
}

/* ----- login screen ----- */

#login-screen { text-align: center; }
#login-screen h1 { color: var(--gold); font-size: 3rem; margin-bottom: 0.2em; }
#login-screen p { color: var(--pending); margin-top: 0; }
#login-screen .hint { margin-top: 2em; line-height: 1.7; }
kbd {
  background: var(--panel);
  border: 1px solid var(--pending);
  border-radius: 4px;
  padding: 0.1em 0.45em;
  font-family: "Courier New", monospace;
  color: var(--gold);
}

#player-name {
  font-size: 1.3rem;
  padding: 0.5em 0.8em;
  border: 2px solid var(--pending);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  text-align: center;
}

#login-form button {
  font-size: 1.3rem;
  font-family: inherit;
  margin-left: 0.5em;
  padding: 0.5em 1.2em;
  border: none;
  border-radius: 8px;
  background: var(--gold);
  color: var(--bg);
  cursor: pointer;
}

/* The roster: one button per family member, since only the fixed roster may
   play (see DEFAULT_ROSTER in backend/main.py). */
.roster {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7em;
  justify-content: center;
  margin: 1.5em auto 0;
  max-width: 460px;
}
.roster-name {
  font-size: 1.25rem;
  font-family: inherit;
  padding: 0.55em 1.3em;
  border: 2px solid var(--pending);
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}
.roster-name:hover {
  border-color: var(--gold);
  color: var(--gold);
}
#login-screen .hint a { color: var(--gold); }

/* ----- HUD ----- */

#game-screen {
  width: 100%;
  max-width: 720px;
  text-align: center;
}

#hud {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0.8em 1.2em;
  background: var(--panel);
  border-radius: 10px;
  font-size: 1rem;
}

#hud-player { color: var(--gold); }
.hud-stat { color: var(--pending); }
.hud-stat strong { color: var(--text); font-size: 1.2em; }

#event-banner {
  margin-top: 0.8em;
  padding: 0.6em;
  background: var(--gold);
  color: var(--bg);
  border-radius: 8px;
  font-weight: bold;
}

/* ----- the world canvas and the typing overlay above it ----- */

#game-container {
  position: relative;
  margin-top: 0.8em;
  width: 960px;
  max-width: 100%;
}

#game-container canvas {
  border-radius: 10px;
  display: block;
}

#typing-overlay {
  /* Floats over the Phaser canvas. The canvas stays visible around it, so
     you can watch the spirit closing in while you type — that's the game. */
  position: absolute;
  left: 50%;
  bottom: 12%;
  transform: translateX(-50%);
  padding: 0.6em 1.6em 0.9em;
  background: rgba(42, 40, 67, 0.92);
  border: 2px solid var(--gold);
  border-radius: 12px;
  pointer-events: none; /* clicks pass through to the page (spec) */
}

#word-display {
  font-size: 3rem;
  letter-spacing: 0.12em;
  font-family: "Courier New", monospace; /* every character the same width */
  min-height: 1.3em;
  white-space: nowrap;
}

/* The combat panel floats over the canvas, right above the monster you're
   fighting. game.js sets its left/top each frame from WorldScene's report;
   the transform pins its bottom-centre to that point (just over the head). */
#combat-overlay {
  position: absolute;
  left: 0;
  top: 0;
  transform: translate(-50%, -100%);
  padding: 0.2em 0.6em 0.3em;
  background: rgba(28, 27, 46, 0.92);
  border: 2px solid var(--gold);
  border-radius: 9px;
  pointer-events: none;
  white-space: nowrap;
}

#combat-display {
  font-size: 1.5rem;
  letter-spacing: 0.1em;
  font-family: "Courier New", monospace;
  line-height: 1.1;
}

#overlay-hint {
  margin-top: 0.4em;
  font-size: 0.85rem;
  color: var(--pending);
}

.char-pending { color: var(--pending); }
.char-correct { color: var(--correct); }
.char-error {
  color: var(--error);
  text-decoration: underline;
}
.char-current { border-bottom: 3px solid var(--gold); }

/* The 80ms green flash on a completed word (spec: "game feel"). */
.word-complete span { color: var(--correct); text-shadow: 0 0 18px var(--correct); }

/* The input is real and focused (that's how we get keys), just invisible.
 * opacity instead of display:none — hidden inputs can't hold focus. */
#typing-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 1px;
  height: 1px;
}

/* "+12 XP" floats up from the word and fades (spec: "game feel"). Used by
   both the practice panel (#xp-float) and the combat panel (#combat-xp). */
.xp-float {
  position: absolute;
  left: 50%;
  top: -1.4em;
  transform: translateX(-50%);
  color: var(--gold);
  font-size: 1.4rem;
  pointer-events: none;
  opacity: 0;
}
.xp-float.floating { animation: float-up 0.9s ease-out; }

@keyframes float-up {
  0%   { opacity: 1; transform: translate(-50%, 0); }
  100% { opacity: 0; transform: translate(-50%, -2.2em); }
}

#disconnected {
  position: fixed;
  bottom: 1em;
  left: 50%;
  transform: translateX(-50%);
  background: var(--error);
  color: var(--text);
  padding: 0.6em 1.2em;
  border-radius: 8px;
}
