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

html, body {
  height: 100%;
  background: #05050a;
  color: #fff;
  font-family: "Trebuchet MS", "Helvetica Neue", sans-serif;
  overflow: hidden;
  user-select: none;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background:
    radial-gradient(ellipse at top, #4a1860 0%, #0a0414 65%),
    repeating-linear-gradient(0deg, rgba(255,255,255,0.02) 0 2px, transparent 2px 4px);
}

.hidden { display: none !important; }

/* ---------- MENU ---------- */
.overlay {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  padding: 40px;
  text-align: center;
  position: relative;
}

.title {
  font-size: 72px;
  letter-spacing: 8px;
  font-weight: 900;
  color: #fff;
  text-shadow:
    0 0 18px #ffb800,
    4px 4px 0 #6d0000,
    -2px -2px 0 #ff3333;
  animation: titlePulse 2.4s ease-in-out infinite;
}
.title .accent { color: #ffb800; }
@keyframes titlePulse {
  0%, 100% { text-shadow: 0 0 18px #ffb800, 4px 4px 0 #6d0000, -2px -2px 0 #ff3333; }
  50%      { text-shadow: 0 0 32px #ffe066, 4px 4px 0 #6d0000, -2px -2px 0 #ff3333; }
}

.subtitle {
  color: #d2c4ff;
  letter-spacing: 4px;
  font-size: 14px;
  text-transform: uppercase;
  margin-bottom: 12px;
}

.buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  max-width: 540px;
  width: 100%;
}
.buttons button:first-child,
.buttons button:nth-child(2) {
  grid-column: span 1;
}

.buttons button {
  background: linear-gradient(180deg, #ff3a3a, #8a0000);
  color: white;
  border: 2px solid #ffb800;
  padding: 16px 22px;
  font-size: 17px;
  font-weight: bold;
  letter-spacing: 2px;
  cursor: pointer;
  text-transform: uppercase;
  border-radius: 4px;
  transition: transform 0.08s, box-shadow 0.12s;
  box-shadow: 0 4px 0 #4a0000, inset 0 1px 0 rgba(255,255,255,0.3);
}
.buttons button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 14px #ff3a3a55, 0 6px 0 #4a0000, inset 0 1px 0 rgba(255,255,255,0.3);
}
.buttons button:active { transform: translateY(2px); box-shadow: 0 2px 0 #4a0000; }

.buttons button.settings-btn {
  grid-column: span 2;
  background: linear-gradient(180deg, #4a4a6a, #1a1a2a);
  border-color: #888;
  box-shadow: 0 4px 0 #0a0a14, inset 0 1px 0 rgba(255,255,255,0.2);
}

/* ---------- LANGUAGE TOGGLE ---------- */
.lang-toggle {
  display: inline-flex;
  border: 2px solid #ffb800;
  border-radius: 4px;
  overflow: hidden;
}
.lang-toggle.top-right {
  position: absolute;
  top: 20px;
  right: 30px;
}
.lang-toggle button {
  background: #1a0a2e;
  color: #fff;
  border: none;
  padding: 6px 14px;
  font-weight: bold;
  font-size: 13px;
  letter-spacing: 2px;
  cursor: pointer;
}
.lang-toggle button.active {
  background: #ffb800;
  color: #000;
}

/* ---------- SETTINGS ---------- */
.settings-box {
  background: rgba(0,0,0,0.4);
  border: 2px solid #ffb800;
  padding: 26px 36px;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 380px;
}
.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  color: #fff;
  letter-spacing: 2px;
  font-size: 15px;
}
.setting-row label:first-child {
  color: #ffe066;
}
.setting-row.column {
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}
.setting-row.column input[type=text] {
  background: #1a0a2e;
  border: 2px solid #ffb800;
  color: #fff;
  font-size: 14px;
  padding: 8px 10px;
  border-radius: 4px;
  font-family: "Courier New", monospace;
}
.setting-help { color: #aaa; font-size: 11px; letter-spacing: 1px; }
.switch {
  position: relative;
  display: inline-block;
  width: 56px;
  height: 28px;
  flex-shrink: 0;
}
.switch input { display: none; }
.switch .slider {
  position: absolute;
  inset: 0;
  background: #333;
  border: 2px solid #777;
  border-radius: 28px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
.switch .slider::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: #ccc;
  border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}
.switch input:checked + .slider {
  background: #aa3000;
  border-color: #ffb800;
}
.switch input:checked + .slider::before {
  transform: translateX(28px);
  background: #ffe066;
  box-shadow: 0 0 8px #ffb800;
}

.controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-top: 18px;
  max-width: 640px;
}

.player-controls {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,184,0,0.4);
  border-radius: 6px;
  padding: 14px 18px;
  text-align: left;
  font-size: 13px;
}
.player-controls h3 {
  color: #ffb800;
  margin-bottom: 8px;
  letter-spacing: 2px;
  font-size: 13px;
}
.player-controls ul { list-style: none; }
.player-controls li { padding: 2px 0; color: #ddd; }
.player-controls b { color: #fff; }

/* ---------- ONLINE PANEL ---------- */
.online-box {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  background: rgba(0,0,0,0.4);
  border: 2px solid #ffb800;
  padding: 28px 40px;
  border-radius: 6px;
  min-width: 360px;
}
.online-box label {
  color: #ffb800;
  letter-spacing: 3px;
  font-size: 13px;
}
.online-box input {
  font-size: 32px;
  font-weight: bold;
  letter-spacing: 8px;
  text-align: center;
  background: #1a0a2e;
  border: 2px solid #ffb800;
  color: #fff;
  padding: 8px 14px;
  border-radius: 4px;
  width: 280px;
  text-transform: uppercase;
}
.online-box button {
  background: linear-gradient(180deg, #44dd44, #117711);
  border: 2px solid #fff;
  color: #fff;
  padding: 10px 28px;
  font-size: 16px;
  font-weight: bold;
  letter-spacing: 3px;
  cursor: pointer;
  border-radius: 4px;
}
.status { color: #ffd; min-height: 20px; font-size: 13px; letter-spacing: 1px; }

/* ---------- GAME ---------- */
#game-ui {
  position: relative;
  width: 1024px;
  max-width: 100%;
}

.hud {
  display: grid;
  grid-template-columns: 1fr 200px 1fr;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  background: linear-gradient(180deg, #1a0a2e 0%, #0a0414 100%);
  border: 2px solid #ffb800;
  border-bottom: none;
  box-shadow: 0 0 20px rgba(255,184,0,0.3);
}

.side {
  display: flex;
  align-items: center;
  gap: 10px;
}
.side.right { flex-direction: row-reverse; }
.side .meta { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.side.right .meta { align-items: flex-end; }

.portrait {
  width: 54px;
  height: 54px;
  border: 2px solid #ffb800;
  background: #000;
  border-radius: 4px;
  flex-shrink: 0;
}

.name {
  font-weight: bold;
  letter-spacing: 2px;
  color: #ffb800;
  font-size: 15px;
  text-shadow: 1px 1px 0 #000;
}

.bar {
  width: 100%;
  height: 20px;
  background: #1a1a1a;
  border: 2px solid #fff;
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.6);
}
.bar.super { height: 8px; border-color: #66ccff; box-shadow: inset 0 1px 2px rgba(0,0,0,0.6); }

.hp {
  height: 100%;
  width: 100%;
  background: linear-gradient(180deg, #ffe600, #ff5500 50%, #aa3300);
  transition: width 0.22s ease-out;
  box-shadow: inset 0 -3px 0 rgba(0,0,0,0.25);
}
.hp.right-bar {
  background: linear-gradient(180deg, #ffe600, #ff5500 50%, #aa3300);
  margin-left: auto;
}

.sp {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #66ccff, #3366ff, #6633ff);
  transition: width 0.18s ease-out;
  box-shadow: 0 0 6px rgba(102,204,255,0.6);
}
.sp.right-bar {
  background: linear-gradient(270deg, #66ccff, #3366ff, #6633ff);
  margin-left: auto;
}

.timer-wrap { text-align: center; }
.timer {
  font-size: 46px;
  font-weight: bold;
  color: #ffe600;
  text-shadow: 2px 2px 0 #000, 0 0 12px rgba(255,230,0,0.6);
  line-height: 1;
  font-family: "Courier New", monospace;
}
.round {
  font-size: 12px;
  letter-spacing: 3px;
  color: #fff;
}
.match-score {
  margin-top: 4px;
  font-size: 14px;
  letter-spacing: 4px;
  font-weight: bold;
  color: #555;
}
.match-score .vs { color: #ffb800; font-size: 11px; }
.match-score .win { color: #ffe600; text-shadow: 0 0 8px #ffe600; }

#stage {
  display: block;
  width: 100%;
  height: auto;
  background: #000;
  border: 2px solid #ffb800;
  box-shadow: 0 0 20px rgba(255,184,0,0.3);
}

.message {
  position: absolute;
  top: 45%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 80px;
  font-weight: 900;
  letter-spacing: 8px;
  text-shadow: 4px 4px 0 #000, 0 0 28px #ffb800, -2px -2px 0 #ff3333;
  color: #ffe600;
  pointer-events: none;
  text-align: center;
  animation: msgPop 0.4s ease-out;
}
@keyframes msgPop {
  0%   { transform: translate(-50%, -50%) scale(0.4); opacity: 0; }
  60%  { transform: translate(-50%, -50%) scale(1.15); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

.online-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 24px;
  letter-spacing: 4px;
  z-index: 5;
}
.online-overlay .room-label {
  margin-top: 14px;
  font-size: 16px;
  color: #ffb800;
}
.online-overlay .room-label span {
  font-size: 32px;
  letter-spacing: 8px;
}

.continue-panel {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: radial-gradient(ellipse at center, rgba(20,0,30,0.85) 0%, rgba(0,0,0,0.95) 80%);
  z-index: 8;
  animation: fadeIn 0.4s ease-out;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.continue-panel .winner-line {
  font-size: 28px;
  letter-spacing: 5px;
  color: #ffe066;
  text-shadow: 2px 2px 0 #000, 0 0 18px #ffb800;
  margin-bottom: 8px;
}
.continue-panel .continue-title {
  font-size: 84px;
  font-weight: 900;
  letter-spacing: 10px;
  color: #fff;
  text-shadow: 4px 4px 0 #6d0000, -2px -2px 0 #ff3333, 0 0 30px #ff5533;
  animation: continuePulse 0.9s ease-in-out infinite;
}
@keyframes continuePulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.04); }
}
.continue-panel .continue-count {
  font-family: "Courier New", monospace;
  font-size: 96px;
  font-weight: bold;
  color: #ff3333;
  text-shadow: 4px 4px 0 #000, 0 0 24px #ff3333;
  line-height: 1;
  width: 130px;
  height: 130px;
  border: 4px solid #ffb800;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.5);
  box-shadow: 0 0 30px rgba(255,184,0,0.5), inset 0 0 20px rgba(255,51,51,0.3);
}
.continue-panel .continue-buttons {
  display: flex;
  gap: 18px;
  margin-top: 8px;
}
.continue-panel .continue-buttons button {
  background: linear-gradient(180deg, #ff3a3a, #8a0000);
  color: white;
  border: 2px solid #ffb800;
  padding: 14px 38px;
  font-size: 20px;
  font-weight: bold;
  letter-spacing: 4px;
  cursor: pointer;
  text-transform: uppercase;
  border-radius: 4px;
  box-shadow: 0 4px 0 #4a0000, inset 0 1px 0 rgba(255,255,255,0.3);
}
.continue-panel .continue-buttons button:hover {
  transform: translateY(-2px);
}
.continue-panel .continue-buttons #quit-btn {
  background: linear-gradient(180deg, #555, #222);
  border-color: #888;
  box-shadow: 0 4px 0 #111, inset 0 1px 0 rgba(255,255,255,0.2);
}
.continue-panel .continue-hint {
  color: #aaa;
  font-size: 13px;
  letter-spacing: 2px;
  margin-top: 12px;
}
.continue-panel .continue-hint b { color: #ffe066; }

.back {
  position: absolute;
  top: 10px;
  right: 14px;
  background: #222;
  color: #fff;
  border: 1px solid #ffb800;
  padding: 6px 14px;
  cursor: pointer;
  font-weight: bold;
  letter-spacing: 1px;
  border-radius: 3px;
  z-index: 10;
}
.back:hover { background: #ffb800; color: #000; }
