* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(59, 130, 246, 0.28), transparent 32%),
    radial-gradient(circle at bottom right, rgba(124, 58, 237, 0.22), transparent 35%),
    #020617;
  color: #f8fafc;
}

button,
input {
  font-family: inherit;
}

.hidden {
  display: none !important;
}

.screen {
  min-height: 100vh;
}

.login-screen {
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 440px;
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 28px;
  padding: 30px;
  box-shadow: 0 35px 90px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(16px);
}

.login-card h1 {
  margin: 0 0 10px;
  font-size: 34px;
  letter-spacing: -0.04em;
}

.login-card p {
  margin: 0 0 20px;
  color: #cbd5e1;
}

.login-card label {
  display: block;
  margin: 14px 0 6px;
  font-size: 13px;
  font-weight: 800;
  color: #e2e8f0;
}

.login-card input {
  width: 100%;
  padding: 14px 15px;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(2, 6, 23, 0.78);
  color: white;
  outline: none;
  font-size: 15px;
}

.login-card input:focus {
  border-color: #60a5fa;
  box-shadow: 0 0 0 4px rgba(96, 165, 250, 0.18);
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 18px 0 8px;
}

button {
  border: 0;
  cursor: pointer;
  border-radius: 14px;
  padding: 12px 16px;
  font-weight: 900;
  color: white;
  background: #334155;
  transition: transform 0.12s ease, filter 0.12s ease, opacity 0.12s ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(1.08);
}

button:active:not(:disabled) {
  transform: translateY(0);
}

.tab {
  background: rgba(51, 65, 85, 0.95);
}

.tab.active,
.main-btn,
#newGameBtn,
#voiceBtn {
  background: linear-gradient(135deg, #2563eb, #7c3aed);
}

.main-btn {
  width: 100%;
  margin-top: 18px;
  padding: 15px 18px;
}

.error {
  margin-top: 14px !important;
  color: #fca5a5 !important;
  font-weight: 800;
  min-height: 22px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  flex-wrap: wrap;
  padding: 22px;
}

.topbar h1 {
  margin: 0;
  font-size: 34px;
  letter-spacing: -0.04em;
}

#status {
  margin: 8px 0 0;
  color: #cbd5e1;
  font-weight: 700;
}

#roomLabel {
  margin: 6px 0 0;
  color: #facc15;
  font-weight: 900;
}

.controls,
.voice-controls {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
  padding: 14px;
  border-radius: 22px;
  background: rgba(15, 23, 42, 0.78);
  border: 1px solid rgba(148, 163, 184, 0.24);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}

.controls label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  font-weight: 900;
  color: #cbd5e1;
}

.controls input {
  width: 82px;
  border: 0;
  outline: none;
  padding: 10px;
  border-radius: 12px;
  background: #e2e8f0;
  color: #020617;
  font-weight: 800;
}

.voice-controls {
  align-items: center;
}

#muteBtn {
  background: #475569;
}

#muteBtn.active {
  background: #dc2626;
}

#voiceStatus {
  color: #cbd5e1;
  font-weight: 800;
  font-size: 14px;
}

button:disabled {
  opacity: 0.42;
  cursor: not-allowed;
  filter: grayscale(1);
}

.info {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  padding: 0 22px 18px;
}

.info div {
  padding: 11px 15px;
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.82);
  border: 1px solid rgba(148, 163, 184, 0.22);
  color: #cbd5e1;
  font-weight: 800;
}

.info strong {
  color: white;
}

.game-layout {
  display: flex;
  align-items: flex-start;
  gap: 18px;
  padding: 0 22px 22px;
}

#boardWrap {
  position: relative;
  width: fit-content;
  max-width: 100%;
  overflow: auto;
  padding: 14px;
  border-radius: 24px;
  background: rgba(15, 23, 42, 0.78);
  border: 1px solid rgba(148, 163, 184, 0.22);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
}

#board {
  display: grid;
  gap: 4px;
  user-select: none;
}

.tile {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 1000;
  background: linear-gradient(145deg, #475569, #1e293b);
  color: white;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    inset 0 -3px 0 rgba(0, 0, 0, 0.32);
}

.tile:hover {
  outline: 2px solid #38bdf8;
  outline-offset: 1px;
}

.tile.revealed {
  background: #e2e8f0;
  color: #0f172a;
  box-shadow: none;
  cursor: default;
}

.tile.flagged {
  background: linear-gradient(145deg, #f59e0b, #92400e);
}

.tile.mine {
  background: linear-gradient(145deg, #ef4444, #7f1d1d);
  color: white;
}

.n1 { color: #2563eb; }
.n2 { color: #16a34a; }
.n3 { color: #dc2626; }
.n4 { color: #7c3aed; }
.n5 { color: #be123c; }
.n6 { color: #0891b2; }
.n7 { color: #111827; }
.n8 { color: #475569; }

.players-panel {
  width: 270px;
  min-width: 240px;
  padding: 16px;
  border-radius: 24px;
  background: rgba(15, 23, 42, 0.82);
  border: 1px solid rgba(148, 163, 184, 0.22);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.25);
}

.players-panel h2 {
  margin: 0 0 14px;
  font-size: 22px;
  letter-spacing: -0.03em;
}

.player-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 9px;
  padding: 11px;
  border-radius: 16px;
  background: rgba(30, 41, 59, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.18);
}

.player-row.owner {
  background: rgba(113, 63, 18, 0.55);
  border-color: rgba(250, 204, 21, 0.72);
}

.player-row.owner .player-name {
  color: #facc15;
  font-weight: 1000;
}

.player-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 800;
}

.kick-btn {
  padding: 8px 10px;
  border-radius: 11px;
  background: #991b1b;
  font-size: 12px;
}

#cursors {
  position: absolute;
  inset: 0;
  z-index: 20;
  pointer-events: none;
}

.cursor {
  position: absolute;
  transform: translate(-3px, -3px);
  pointer-events: none;
  white-space: nowrap;
  will-change: left, top;
}

.cursor .arrow {
  font-size: 23px;
  line-height: 1;
  text-shadow: 0 2px 4px black;
}

.cursor .name {
  display: inline-block;
  margin-left: 16px;
  margin-top: -6px;
  padding: 4px 8px;
  border-radius: 999px;
  color: white;
  font-size: 13px;
  font-weight: 900;
  text-shadow: 0 1px 2px black;
}

#remoteAudios {
  display: none;
}

@media (max-width: 900px) {
  .game-layout {
    flex-direction: column;
  }

  .players-panel {
    width: 100%;
  }
}