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

:root {
  --bg: #1a1a2e;
  --surface: #16213e;
  --accent: #e94560;
  --accent2: #4ecdc4;
  --text: #eee;
  --muted: #8899aa;
  --radius: 12px;
}

html, body {
  height: 100%;
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

#app {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.screen {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 2rem;
  width: 100%;
  max-width: 900px;
  animation: fadeIn 0.3s ease;
}

.screen.active {
  display: flex;
}

#screen-game {
  max-width: 100%;
  height: 100vh;
  padding: 0.5rem;
  gap: 0.4rem;
}

#screen-game.active {
  justify-content: flex-start;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.logo h1 {
  font-size: 3rem;
  background: linear-gradient(135deg, var(--accent2), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-align: center;
}

.tagline {
  text-align: center;
  color: var(--muted);
  margin-top: 0.25rem;
}

.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
  max-width: 280px;
  margin-top: 1rem;
}

.btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--surface);
  color: var(--text);
  transition: transform 0.15s, background 0.15s;
}

.btn:hover {
  transform: translateY(-2px);
  background: #1f3460;
}

.btn.primary {
  background: linear-gradient(135deg, var(--accent2), #3aa89f);
  color: #111;
}

.btn.primary:hover {
  background: linear-gradient(135deg, #5eddd4, var(--accent2));
}

.btn.ghost {
  background: transparent;
  border: 1px solid var(--muted);
  color: var(--muted);
}

.btn.small {
  padding: 0.35rem 0.75rem;
  font-size: 0.85rem;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

h2 {
  font-size: 1.75rem;
  margin-bottom: 0.5rem;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  width: 100%;
  max-width: 320px;
  font-size: 0.9rem;
  color: var(--muted);
}

input[type="text"],
select {
  padding: 0.6rem 0.8rem;
  border: 1px solid #334;
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
}

input[type="range"] {
  width: 100%;
}

.checkbox {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}

hr {
  width: 100%;
  max-width: 320px;
  border: none;
  border-top: 1px solid #334;
  margin: 0.5rem 0;
}

.error {
  color: var(--accent);
  font-size: 0.9rem;
  min-height: 1.2em;
}

.hint {
  color: var(--muted);
  font-size: 0.85rem;
}

.status {
  color: var(--accent2);
}

.lobby-code {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.2rem;
}

.lobby-code strong {
  font-size: 2rem;
  letter-spacing: 0.2em;
  color: var(--accent2);
}

.lobby-players {
  text-align: center;
  line-height: 1.8;
}

.canvas-wrap {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0d1117;
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 0;
}

#game-canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
}

.hud-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 0.25rem 0.5rem;
  background: var(--surface);
  border-radius: 8px;
  font-size: 0.85rem;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.hud-left, .hud-center, .hud-right {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.hud-turn {
  font-weight: 700;
  color: var(--accent2);
}

.hud-timer {
  color: var(--accent);
  font-weight: 600;
}

.hud-bottom {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  width: 100%;
  gap: 0.5rem;
}

.team-panel {
  background: var(--surface);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  min-width: 140px;
  font-size: 0.8rem;
}

.team-header {
  font-weight: 700;
  margin-bottom: 0.35rem;
}

.buddy-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.15rem 0;
  opacity: 0.7;
}

.buddy-row.active {
  opacity: 1;
  font-weight: 600;
}

.buddy-row.dead {
  text-decoration: line-through;
  opacity: 0.3;
}

.mini-hp {
  flex: 1;
  height: 4px;
  background: #333;
  border-radius: 2px;
  overflow: hidden;
}

.mini-hp div {
  height: 100%;
  background: #4caf50;
  transition: width 0.3s;
}

.hud-message {
  font-size: 2rem;
  align-self: center;
}

.controls-hint {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
  font-size: 0.75rem;
  color: var(--muted);
  padding: 0.25rem;
}

.results-body {
  text-align: center;
  line-height: 2;
  font-size: 1.1rem;
}

.howto-content {
  max-width: 520px;
  line-height: 1.7;
  max-height: 60vh;
  overflow-y: auto;
  padding-right: 0.5rem;
}

.howto-content h3 {
  margin-top: 1rem;
  color: var(--accent2);
}

.howto-content ul {
  padding-left: 1.5rem;
}

@media (max-width: 600px) {
  .logo h1 { font-size: 2rem; }
  .hud-top { font-size: 0.75rem; }
  .controls-hint { display: none; }
  .team-panel { min-width: 100px; font-size: 0.7rem; }
}
