:root {
  --bg-top: #edf6f7;
  --bg-bottom: #dbe8e4;
  --panel: #fcfbf8;
  --line: rgba(47, 68, 77, 0.14);
  --text: #1f2d35;
  --muted: #5d6b75;
  --accent: #1f7a8c;
  --accent-dark: #155d6b;
  --success: #2f9f6b;
  --shadow: 0 14px 34px rgba(33, 48, 58, 0.1);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  color: var(--text);
  font-family: "Trebuchet MS", "Segoe UI", Tahoma, sans-serif;
  background: linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.reload-hotspot {
  position: fixed;
  z-index: 10;
  top: 0;
  right: 0;
  width: 96px;
  height: 96px;
  opacity: 0.01;
}

.page-shell {
  width: min(1920px, 100vw);
  height: calc(100vh - 74px);
  margin: 0 auto;
  padding: 18px 20px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(330px, 430px) 1fr;
  gap: 18px;
  height: 100%;
}

.panel-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 26px;
  box-shadow: var(--shadow);
}

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 22px;
}

.brand-block {
  flex: 0 0 auto;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent-dark);
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.35rem, 3vw, 3.55rem);
  line-height: 0.94;
}

h2 {
  margin: 0 0 12px;
  font-size: 1.25rem;
}

.status-card,
.stats-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.66);
}

.status-message {
  margin: 0;
  color: var(--muted);
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.35;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.stat-box {
  min-height: 58px;
  padding: 9px;
  border-radius: 16px;
  background: #fff;
}

.stat-label {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.stat-box strong {
  display: block;
  margin-top: 4px;
  font-size: 1.15rem;
}

.exit-link {
  display: grid;
  min-height: 54px;
  margin-top: auto;
  color: #fff;
  text-decoration: none;
  border-radius: 18px;
  background: #2c3840;
  font-size: 1.12rem;
  font-weight: 700;
  place-items: center;
}

.main-panel {
  display: grid;
  min-height: 0;
  padding: 28px;
}

.lobby-view,
.game-view {
  min-height: 100%;
}

.lobby-view {
  display: grid;
  grid-template-rows: auto min-content 1fr;
  gap: 22px;
}

.lobby-header h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.1rem, 2.6vw, 3.05rem);
  line-height: 1;
}

.lobby-actions {
  display: grid;
  grid-template-columns: 1fr 1.08fr 1fr;
  gap: 18px;
  align-items: stretch;
  align-self: start;
  height: 320px;
}

.lobby-card {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  min-height: 0;
  height: 100%;
  padding: 28px;
  text-align: left;
  border: 2px solid rgba(31, 122, 140, 0.16);
  border-radius: 24px;
  background: #fff;
  box-shadow: 0 12px 28px rgba(33, 48, 58, 0.08);
}

button.lobby-card:focus-visible,
button.lobby-card:hover,
.join-card:focus-within {
  outline: none;
  border-color: rgba(31, 122, 140, 0.5);
}

.lobby-card strong,
.lobby-card label {
  display: block;
  margin-bottom: 12px;
  color: var(--text);
  font-size: clamp(1.55rem, 1.85vw, 2.05rem);
  font-weight: 800;
  line-height: 1.05;
}

.lobby-card span {
  color: var(--muted);
  font-size: 1.08rem;
  font-weight: 700;
  line-height: 1.35;
}

.lobby-input {
  width: 100%;
  min-height: 64px;
  margin: 10px 0 16px;
  padding: 0 18px;
  text-align: center;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #f8fbfb;
  font-size: 2.1rem;
  font-weight: 800;
  letter-spacing: 0.18em;
}

.primary-button,
.secondary-button {
  min-height: 60px;
  border-radius: 18px;
  font-size: 1.12rem;
  font-weight: 800;
}

.primary-button {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
}

.secondary-button {
  color: var(--accent-dark);
  background: #e7f3f4;
}

.waiting-panel {
  display: grid;
  justify-items: center;
  gap: 12px;
  align-self: end;
  padding: 22px;
  border: 2px solid rgba(47, 159, 107, 0.28);
  border-radius: 24px;
  background: #f7fcf9;
}

.waiting-label,
.waiting-copy {
  margin: 0;
  color: var(--muted);
  font-size: 1.2rem;
  font-weight: 700;
  text-align: center;
}

.large-code {
  color: var(--accent-dark);
  font-size: clamp(4rem, 9vw, 8rem);
  font-weight: 900;
  letter-spacing: 0.14em;
  line-height: 0.95;
}

.game-view {
  display: grid;
  grid-template-rows: 1fr auto;
  place-items: center;
}

.board {
  display: grid;
  grid-template-columns: repeat(3, minmax(118px, 190px));
  grid-template-rows: repeat(3, minmax(118px, 190px));
  gap: 14px;
}

.cell {
  min-width: 0;
  min-height: 0;
  color: var(--accent-dark);
  border: 3px solid rgba(31, 122, 140, 0.22);
  border-radius: 24px;
  background: #fff;
  font-size: clamp(3.4rem, 8vw, 6.4rem);
  font-weight: 800;
}

.cell.win {
  color: #fff;
  background: var(--success);
}

.turn-banner {
  margin-top: 18px;
  color: var(--muted);
  font-size: 1.3rem;
  font-weight: 800;
}

[hidden] {
  display: none !important;
}

@media (max-width: 1080px) {
  body { overflow: auto; }
  .page-shell { height: auto; min-height: 100vh; }
  .layout { grid-template-columns: 1fr; }
  .lobby-actions { grid-template-columns: 1fr; }
  .lobby-card { min-height: 190px; }
}
