:root {
  --bg: #04101d;
  --bg-2: #082a42;
  --panel: rgba(7, 32, 52, 0.78);
  --panel-solid: #0a2941;
  --line: rgba(112, 210, 255, 0.16);
  --line-strong: rgba(112, 210, 255, 0.34);
  --text: #eaf7ff;
  --muted: #8fb3c9;
  --cyan: #46d5ff;
  --cyan-deep: #1e9dcb;
  --gold: #ffd166;
  --red: #ff5d6c;
  --green: #52e0a4;
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.45);
  --radius: 20px;
  --radius-sm: 12px;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  font-family: "Segoe UI", "Trebuchet MS", system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
a { color: inherit; }
[hidden] { display: none !important; }

:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
}

.ocean {
  position: fixed;
  inset: 0;
  z-index: -2;
  overflow: hidden;
  background:
    radial-gradient(1100px 700px at 12% -10%, rgba(29, 126, 173, 0.35), transparent 60%),
    radial-gradient(900px 600px at 108% 6%, rgba(22, 88, 140, 0.38), transparent 62%),
    linear-gradient(180deg, #04111f 0%, #071f33 48%, #030d18 100%);
}

.ocean-glow {
  position: absolute;
  inset: auto -20% -45% -20%;
  height: 75%;
  background: radial-gradient(closest-side, rgba(54, 196, 244, 0.16), transparent);
  filter: blur(18px);
}

.wave {
  position: absolute;
  left: -20%;
  width: 140%;
  height: 240px;
  opacity: 0.22;
  border-radius: 48%;
  background: repeating-linear-gradient(100deg, transparent 0 70px, rgba(96, 214, 255, 0.09) 70px 72px);
}

.wave-1 { bottom: -110px; animation: drift 20s ease-in-out infinite alternate; }
.wave-2 { bottom: -160px; opacity: 0.14; animation: drift 30s ease-in-out infinite alternate-reverse; }

@keyframes drift {
  from { transform: translateX(-2.5%) rotate(-1.5deg); }
  to { transform: translateX(2.5%) rotate(1.5deg); }
}

.topbar {
  position: relative;
  z-index: 5;
  max-width: 1240px;
  margin: 0 auto;
  padding: 22px 28px 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  user-select: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  font-size: 24px;
  background: linear-gradient(150deg, rgba(70, 213, 255, 0.22), rgba(70, 213, 255, 0.04));
  border: 1px solid var(--line-strong);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35), inset 0 0 18px rgba(70, 213, 255, 0.12);
}

.brand-text {
  font-size: 13px;
  line-height: 1.05;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--muted);
}

.top-actions { display: flex; gap: 10px; }

.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(8, 34, 54, 0.65);
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
  transition: border-color 0.2s, transform 0.2s, background 0.2s;
}

.icon-btn:hover { border-color: var(--line-strong); transform: translateY(-2px); background: rgba(13, 48, 74, 0.9); }

#app {
  max-width: 1180px;
  margin: 0 auto;
  padding: 8px 28px 70px;
}

.screen { display: none; }
body.modal-open { overflow: hidden; }
.screen.active { display: block; animation: screenIn 0.4s ease both; }

@keyframes screenIn {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

.eyebrow {
  margin: 0 0 10px;
  font-size: 12px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--cyan);
  font-weight: 700;
}

h1, h2, h3, p { margin-top: 0; }
h2 { font-size: clamp(1.7rem, 3vw, 2.4rem); margin-bottom: 10px; letter-spacing: -0.02em; }
h3 { font-size: 1.15rem; margin-bottom: 10px; }

.menu-hero { max-width: 820px; padding: 34px 0 20px; }

.menu-hero h1 {
  margin: 0 0 20px;
  font-size: clamp(3rem, 9vw, 6.4rem);
  line-height: 0.92;
  letter-spacing: -0.045em;
  font-weight: 800;
  text-transform: uppercase;
  background: linear-gradient(100deg, #ffffff 10%, #d8f5ff 40%, var(--cyan) 95%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 18px 40px rgba(34, 160, 210, 0.28));
}

.menu-hero h1 span { color: transparent; background: linear-gradient(120deg, var(--gold), #ff9f5a); -webkit-background-clip: text; background-clip: text; }

.lead {
  max-width: 620px;
  font-size: clamp(1rem, 1.8vw, 1.18rem);
  line-height: 1.65;
  color: #b9d7e8;
  margin-bottom: 0;
}

.name-row { max-width: 340px; margin: 18px 0 26px; }

.field { display: block; }

.field span {
  display: block;
  margin-bottom: 8px;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}

.field input, .code-input {
  width: 100%;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(4, 20, 34, 0.72);
  color: var(--text);
  font-size: 1rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.field input:focus, .code-input:focus {
  outline: none;
  border-color: var(--cyan);
  box-shadow: 0 0 0 4px rgba(70, 213, 255, 0.12);
}

.field input::placeholder, .code-input::placeholder { color: #52758b; }

.menu-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  align-items: stretch;
}

.card {
  position: relative;
  padding: 26px;
  border-radius: var(--radius);
  background: linear-gradient(165deg, rgba(10, 42, 66, 0.82), rgba(5, 22, 37, 0.78));
  border: 1px solid var(--line);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(10px);
}

.mode-card { display: flex; flex-direction: column; gap: 8px; }
.mode-card p { color: var(--muted); line-height: 1.55; }
.mode-card .btn { margin-top: auto; }

.card-icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  margin-bottom: 14px;
  border-radius: 15px;
  font-size: 26px;
  background: rgba(70, 213, 255, 0.09);
  border: 1px solid var(--line);
}

.mini-list {
  margin: 0 0 18px;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.9;
}

.mini-list li::before { content: "◦"; color: var(--cyan); margin-right: 8px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 22px;
  border-radius: 14px;
  border: 1px solid var(--line-strong);
  background: rgba(13, 50, 77, 0.72);
  color: var(--text);
  font-weight: 700;
  letter-spacing: 0.02em;
  transition: transform 0.18s, box-shadow 0.18s, background 0.18s, border-color 0.18s;
}

.btn:hover:not(:disabled) { transform: translateY(-2px); background: rgba(18, 66, 100, 0.9); box-shadow: 0 12px 30px rgba(0, 0, 0, 0.3); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: 0.42; cursor: not-allowed; }

.btn.primary {
  border-color: rgba(70, 213, 255, 0.5);
  background: linear-gradient(135deg, #1fb7e7, #147ba6);
  color: #041420;
  box-shadow: 0 12px 34px rgba(30, 170, 220, 0.28);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.18);
}

.btn.primary:hover:not(:disabled) { background: linear-gradient(135deg, #45d1fb, #1a96c7); box-shadow: 0 16px 40px rgba(49, 196, 245, 0.4); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--muted); }
.btn.ghost:hover:not(:disabled) { color: var(--text); border-color: var(--line-strong); background: rgba(11, 42, 65, 0.6); }
.btn.wide { width: 100%; }
.btn.small { padding: 10px 14px; font-size: 0.88rem; border-radius: 11px; }
.btn.back { padding: 9px 15px; font-size: 0.88rem; }

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  margin: 8px 0 18px;
  border-radius: 14px;
  background: rgba(3, 16, 28, 0.72);
  border: 1px solid var(--line);
}

.segmented button {
  padding: 10px 6px;
  border-radius: 10px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
  transition: background 0.2s, color 0.2s;
}

.segmented button:hover { color: var(--text); }
.segmented button.active { background: linear-gradient(140deg, rgba(70, 213, 255, 0.28), rgba(70, 213, 255, 0.08)); color: var(--text); box-shadow: inset 0 0 0 1px rgba(70, 213, 255, 0.22); }

.footnote { margin: 26px 0 0; color: #6d92a9; font-size: 0.86rem; }

.screen-head {
  display: flex;
  align-items: center;
  gap: 18px;
  margin: 22px 0 26px;
}

.screen-head h2 { margin: 0; }
.screen-head .eyebrow { margin-bottom: 4px; }
.room-badge {
  margin-left: auto;
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(5, 24, 40, 0.6);
  color: var(--muted);
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.room-badge strong { color: var(--cyan); letter-spacing: 0.18em; }

.lobby-name-field { max-width: 340px; margin-bottom: 20px; }

.code-input-row { display: flex; gap: 10px; margin-bottom: 10px; }
.code-input {
  text-transform: uppercase;
  letter-spacing: 0.4em;
  font-weight: 800;
  text-align: center;
  min-width: 0;
}

.hint { color: #7fa2b8; font-size: 0.86rem; line-height: 1.6; margin: 10px 0 0; }
.status-line { min-height: 24px; margin: 18px 0 0; color: var(--gold); }

.waiting-card { max-width: 620px; margin: 34px auto 0; text-align: center; }
.room-code {
  margin: 20px auto 6px;
  font-size: clamp(2.6rem, 8vw, 4rem);
  font-weight: 800;
  letter-spacing: 0.22em;
  color: var(--cyan);
  text-shadow: 0 0 32px rgba(70, 213, 255, 0.45);
}
.waiting-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 18px 0; }
.players-list { display: grid; gap: 8px; margin: 18px 0; text-align: left; }
.player-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 12px;
  background: rgba(3, 18, 31, 0.6);
  border: 1px solid var(--line);
  color: var(--muted);
}
.player-row strong { color: var(--text); }
.player-row .tag { margin-left: auto; font-size: 0.76rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--green); }
.player-row.waiting { border-style: dashed; }
.player-row.waiting .tag { color: var(--muted); }
.player-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 10px var(--cyan); }

.spinner-row { display: flex; align-items: center; justify-content: center; gap: 12px; color: var(--muted); margin: 18px 0; }
.spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(70, 213, 255, 0.2);
  border-top-color: var(--cyan);
  animation: spin 0.9s linear infinite;
  display: inline-block;
}
.spinner.big { width: 44px; height: 44px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }

.loading-card { max-width: 480px; margin: 60px auto; text-align: center; display: grid; justify-items: center; gap: 12px; }

.toasts {
  position: fixed;
  left: 50%;
  bottom: max(22px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  width: min(92vw, 460px);
}
.toast {
  padding: 11px 18px;
  border-radius: 12px;
  background: rgba(6, 27, 45, 0.94);
  border: 1px solid var(--line-strong);
  color: var(--text);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.45);
  font-size: 0.92rem;
  animation: toastIn 0.25s ease both;
  text-align: center;
}
.toast.good { border-color: rgba(82, 224, 164, 0.45); }
.toast.bad { border-color: rgba(255, 93, 108, 0.5); }
.toast.gold { border-color: rgba(255, 209, 102, 0.5); }
.toast.leaving { animation: toastOut 0.25s ease both; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px) scale(0.97); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-6px); } }

@media (max-width: 760px) {
  .topbar { padding: 16px 18px 4px; }
  #app { padding: 6px 16px 54px; }
  .menu-grid { grid-template-columns: 1fr; }
  .menu-hero { padding-top: 20px; }
  .card { padding: 20px; }
  .screen-head { flex-wrap: wrap; gap: 12px; }
  .room-badge { margin-left: 0; order: 3; }
}

@media (max-width: 440px) {
  .brand-text { display: none; }
  .name-row { max-width: none; }
  .segmented button { font-size: 0.78rem; }
  .waiting-actions { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}
