@import url('https://fonts.googleapis.com/css2?family=Fraunces:wght@600;700&family=Space+Grotesk:wght@400;500;600&display=swap');

:root {
  --ink: #0d0f14;
  --soft-ink: rgba(13, 15, 20, 0.75);
  --paper: #f7f1e6;
  --amber: #f2b705;
  --cyan: #2ec4b6;
  --rose: #f05d5e;
  --panel: rgba(16, 20, 28, 0.76);
  --panel-light: rgba(247, 241, 230, 0.12);
  --glow: rgba(242, 183, 5, 0.35);
  --border: rgba(247, 241, 230, 0.25);
}

* {
  box-sizing: border-box;
  font-family: 'Space Grotesk', sans-serif;
}

/* Text inputs and selects stay square app-wide. */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="search"],
input[type="url"],
input:not([type]),
textarea,
select {
  border-radius: 0;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--ink);
  color: var(--paper);
}

body {
  min-height: 100vh;
  background-image: url('images/logo.png'), url('images/coverImage.png');
  background-size: 50% auto, cover;
  background-position: center 4%, top center;
  background-repeat: no-repeat, no-repeat;
  background-attachment: scroll, scroll;
}

.screen {
  min-height: 100vh;
  padding: 32px 36px 48px;
  position: relative;
}

#lobby.screen {
  height: 100vh;
  min-height: unset;
  padding: 0;
  overflow: hidden;
}

#room.screen {
  padding: 0;
  overflow: hidden;
}

.screen-active {
  animation: screenFade 0.6s ease;
}

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

.auth-corner {
  position: fixed;
  top: 18px;
  left: 24px;
  z-index: 101;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.auth-links, .auth-user {
  display: flex;
  gap: 10px;
  align-items: center;
}

.auth-name {
  font-weight: 600;
  color: var(--paper);
}

.ghost-btn, .primary-btn {
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--paper);
  padding: 6px 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-weight: 600;
  font-size: 12px;
}

.primary-btn {
  background: var(--amber);
  color: var(--ink);
  border-color: transparent;
  box-shadow: 0 8px 20px var(--glow);
}

.ghost-btn:hover {
  border-color: var(--amber);
  color: var(--amber);
}

.ghost-btn.active {
  background: var(--amber);
  color: var(--ink);
  border-color: transparent;
}

.primary-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(242, 183, 5, 0.45);
}

.lang-picker {
  position: relative;
  display: inline-flex;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(16, 20, 28, 0.55);
}

.lang-picker .lang-btn {
  border: none;
  background: transparent;
  color: var(--paper);
  font-weight: 600;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
  cursor: pointer;
  opacity: 0.7;
  transition: background 0.15s ease, color 0.15s ease, opacity 0.15s ease;
  min-width: 26px;
}

.lang-picker .lang-btn:hover {
  opacity: 1;
  color: var(--amber);
}

.lang-picker .lang-btn.active {
  background: var(--amber);
  color: var(--ink);
  opacity: 1;
}

/* Dropdown collapsed state: only the active button shows. When .open, the
   non-active buttons appear as an absolutely positioned column below the
   trigger, so the surrounding nav bar layout doesn't shift. */
.lang-picker .lang-btn:not(.active) {
  display: none;
}

.lang-picker.open .lang-btn:not(.active) {
  display: block;
  position: absolute;
  left: 3px;
  right: 3px;
  text-align: center;
  background: rgba(16, 20, 28, 0.95);
  border: 1px solid var(--border);
  border-radius: 999px;
  z-index: 50;
  opacity: 1;
}

.lang-picker-sm {
  margin-left: 8px;
  vertical-align: middle;
}

.lang-picker-sm .lang-btn {
  font-size: 10px;
  padding: 2px 6px;
  min-width: 22px;
}

.icon-btn {
  border: none;
  background: transparent;
  color: var(--paper);
  font-weight: 600;
  cursor: pointer;
}

.lobby-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
}

.brand {
  display: none;
}

.brand-title {
  font-family: 'Fraunces', serif;
  font-size: 44px;
  letter-spacing: 2px;
}

.brand-sub {
  font-size: 14px;
  color: var(--soft-ink);
}

.lobby-grid {
  position: fixed;
  top: 56px;
  left: 0;
  bottom: 0;
  width: 400px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 0 16px 16px;
  max-height: calc(100vh - 56px);
}

.panel {
  background: rgba(16, 20, 28, 0.4);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(10px);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.panel-header h3, .panel-block h3 {
  margin: 0 0 4px;
  font-family: Helvetica, Arial, sans-serif;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.panel-tag {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--cyan);
}

.chat-log {
  background: rgba(9, 11, 16, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 14px;
  flex: 1;
  min-height: 80px;
  overflow-y: auto;
  padding: 12px;
  font-size: 12px;
  line-height: 1.4;
}

.chat-panel {
  flex: 0 0 38%;
  min-height: 0;
  max-height: 38%;
  display: flex;
  flex-direction: column;
}

.side-panel {
  flex: 1 1 62%;
  min-height: 0;
  max-height: 62%;
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow-y: auto;
}

.chat-input {
  display: flex;
  gap: 12px;
  margin-top: 14px;
}

.chat-input input,
.pm-input input,
.modal-card input,
select {
  flex: 1;
  border-radius: 0;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(15, 18, 25, 0.5);
  color: var(--paper);
  padding: 8px 10px;
  font-size: 12px;
}

.panel-block {
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.panel-block:last-child {
  border-bottom: none;
}

.list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 120px;
  overflow-y: auto;
}

.list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  font-size: 12px;
}

.list-item button {
  padding: 4px 10px;
  font-size: 11px;
}

.pm-box {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 180px;
}

.pm-box > label {
  font-family: Helvetica, Arial, sans-serif;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.2px;
  color: var(--paper);
}

.pm-input {
  display: flex;
  gap: 8px;
}

.pm-log {
  height: 80px;
  overflow-y: auto;
  font-size: 11px;
  color: rgba(247, 241, 230, 0.8);
  padding: 4px;
  box-sizing: border-box;
}

.room-header {
  display: none;
}

.room-title {
  font-family: 'Fraunces', serif;
  font-size: 16px;
  margin-bottom: 6px;
}

.room-meta {
  display: flex;
  gap: 12px;
  font-size: 11px;
  color: rgba(247, 241, 230, 0.7);
}

.room-actions {
  display: none;
}

.room-grid {
  display: block;
  padding: 0;
  height: 100vh;
}

/* .room-menu[style*="display: none"] ~ .room-stage — not needed anymore */

.room-menu,
.room-panel {
  position: fixed;
  top: 20px;
  left: 20px;
  width: 320px;
  height: fit-content;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  z-index: 20;
}

.room-info-block {
  padding-bottom: 12px;
  margin-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.room-actions-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 12px;
  margin-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.room-actions-block select {
  width: 100%;
}

.room-menu .menu-title {
  font-family: 'Fraunces', serif;
  font-size: 16px;
  margin: 0 0 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.room-menu .menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.menu-btn {
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
  color: var(--paper);
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
}

.menu-btn:hover {
  border-color: var(--amber);
  transform: translateX(2px);
}

.room-actions-aux {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ── New unified panel classes ─────────────────────────────── */

.room-panel {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.panel-section-title {
  font-family: 'Fraunces', serif;
  font-size: 14px;
  font-weight: 600;
  color: rgba(247, 241, 230, 0.75);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin: 10px 0 8px;
  padding: 0;
}

.panel-buttons {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}

/* Whose-turn banner: prominent pulse when it's the local player's turn,
   muted strip otherwise. Hidden in solo / study / spectator modes. */
.turn-banner {
  display: none;
  padding: 8px 12px;
  border-radius: 8px;
  font-family: Helvetica, Arial, sans-serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-align: center;
  margin: 6px 0 8px;
  border: 1px solid transparent;
  transition: all 0.25s ease;
}
.turn-banner.visible { display: block; }
.turn-banner.turn-yours {
  background: rgba(242, 183, 5, 0.18);
  color: var(--amber, #f2b705);
  border-color: var(--amber, #f2b705);
  box-shadow: 0 0 0 0 rgba(242, 183, 5, 0.55);
  animation: turn-pulse 1.4s ease-in-out infinite;
}
.turn-banner.turn-opponent {
  background: rgba(255, 255, 255, 0.04);
  color: rgba(247, 241, 230, 0.5);
  border-color: rgba(255, 255, 255, 0.08);
  animation: none;
  box-shadow: none;
}
@keyframes turn-pulse {
  0%   { box-shadow: 0 0 0 0   rgba(242, 183, 5, 0.55); }
  60%  { box-shadow: 0 0 0 10px rgba(242, 183, 5, 0); }
  100% { box-shadow: 0 0 0 0   rgba(242, 183, 5, 0); }
}

/* Per-player clocks (item 6) */
.clock-box {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 6px 0 8px;
  font-family: Helvetica, Arial, sans-serif;
}
.clock-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(255,255,255,0.04);
  border: 1px solid transparent;
  font-size: 12px;
}
.clock-row.clock-active {
  border-color: var(--amber, #f2b705);
  background: rgba(242, 183, 5, 0.08);
}
.clock-row .clock-label { font-weight: 600; }
.clock-row .clock-time { font-variant-numeric: tabular-nums; font-weight: 700; }
.clock-row .clock-periods {
  font-size: 11px;
  opacity: 0.7;
  font-variant-numeric: tabular-nums;
}

/* Multiplayer transient status toast (challenge sent / declined). */
.mp-status-toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  background: rgba(16, 20, 28, 0.92);
  color: var(--paper, #f7f1e6);
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid var(--amber, #f2b705);
  font-family: Helvetica, Arial, sans-serif;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 6px 24px rgba(0,0,0,0.5);
  pointer-events: none;
  display: none;
}

.panel-row {
  display: flex;
  flex-direction: row;
  gap: 6px;
  margin-bottom: 8px;
}

.panel-btn {
  display: block;
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
  color: var(--paper);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
  line-height: 1.4;
}

.panel-btn span {
  display: block;
  font-size: 11px;
  opacity: 0.6;
  margin-top: 2px;
}

.panel-btn:hover {
  border-color: var(--amber);
  background: rgba(255, 255, 255, 0.09);
  transform: translateX(2px);
}

.panel-btn.accent {
  background: rgba(214, 160, 0, 0.18);
  border-color: var(--amber);
  color: var(--amber);
  font-weight: 600;
}

.panel-btn.accent:hover {
  background: rgba(214, 160, 0, 0.3);
}

.panel-btn-sm {
  flex: 1;
  padding: 8px 4px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
  color: var(--paper);
  font-size: 13px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.panel-btn-sm:hover {
  border-color: var(--amber);
  background: rgba(255, 255, 255, 0.09);
}

.panel-btn-sm.active {
  background: var(--amber);
  color: var(--ink);
  border-color: var(--amber);
}

.panel-back-btn {
  width: 100%;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: transparent;
  color: rgba(247, 241, 230, 0.7);
  font-size: 12px;
  text-align: left;
  cursor: pointer;
  margin-bottom: 8px;
  transition: all 0.2s ease;
}

.panel-back-btn:hover {
  color: var(--paper);
  border-color: rgba(255, 255, 255, 0.25);
}

.panel-info {
  font-size: 12px;
  color: rgba(247, 241, 230, 0.65);
  margin: 4px 0;
  line-height: 1.5;
}

.panel-info strong {
  color: var(--paper);
}

.panel-status {
  display: block;
  font-size: 11px;
  color: rgba(247, 241, 230, 0.5);
  min-height: 14px;
  margin: 2px 0;
}

.panel-aux {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.panel-alert {
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(214, 160, 0, 0.12);
  border: 1px solid rgba(214, 160, 0, 0.3);
  color: var(--amber);
  font-size: 13px;
  margin: 6px 0;
}

.panel-result {
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: var(--paper);
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  margin: 6px 0;
}

.room-actions-row {
  display: flex;
  gap: 8px;
}

.room-actions-row button {
  flex: 1;
}

/* Room chat pinned at panel bottom */
.room-chat-block {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.small-log {
  height: 80px;
  min-height: 80px;
  max-height: 80px;
  overflow-y: auto;
}

/* ── end new panel classes ─────────────────────────────────── */

.room-stage {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: transparent;
  border-radius: 0;
  border: none;
  overflow: hidden;
}

.room-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 6px;
  color: rgba(247, 241, 230, 0.7);
  padding: 40px;
}

.room-placeholder h2 {
  font-family: 'Fraunces', serif;
  font-size: 28px;
  margin: 0;
}

#app {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  background: transparent;
}

canvas {
  display: block;
  position: fixed;
  top: 0;
  left: 0;
  background-color: transparent !important;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

#ui {
  position: fixed;
  top: 20px;
  left: 20px;
  width: 320px;
  background: rgba(255, 255, 255, 0.88);
  color: #111;
  border-radius: 14px;
  padding: 18px 20px 20px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
  z-index: 20;
}

#ui .ui-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

#ui h1 {
  margin: 0;
  font-family: 'Fraunces', serif;
  font-size: 24px;
}

#ui .ui-header .icon-btn {
  font-size: 12px;
  padding: 6px 10px;
  background: rgba(0, 0, 0, 0.08);
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 8px;
  cursor: pointer;
}

#ui .row {
  margin: 6px 0;
  font-size: 13px;
  color: #111;
}

#ui .row span {
  color: #111;
  font-weight: 600;
}

#ui button,
#presetMenu button,
#starDominationMenu button,
.modal-card button {
  display: block;
  width: 100%;
  font-size: 14px;
  padding: 10px 12px;
  margin: 6px 0;
  border-radius: 10px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: rgba(0, 0, 0, 0.06);
  cursor: pointer;
  transition: all 0.2s ease;
}

.modal-card button.primary-btn {
  background: var(--ink);
  color: var(--amber);
  border-color: var(--amber);
}

#ui button:hover,
#presetMenu button:hover,
#starDominationMenu button:hover {
  background: rgba(0, 0, 0, 0.12);
  border-color: rgba(0, 0, 0, 0.2);
}

/* Preset Menu (and parallel Star Domination size picker) */
#presetMenu,
#starDominationMenu {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: min(420px, 90vw);
  background: rgba(16, 20, 28, 0.9);
  color: var(--paper);
  border-radius: 18px;
  padding: 20px 22px;
  z-index: 30;
  border: 1px solid var(--border);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
}

.preset-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.preset-btn {
  font-size: 14px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--paper);
  cursor: pointer;
  transition: all 0.2s ease;
}

.preset-btn:hover {
  border-color: var(--amber);
  transform: translateX(2px);
}

/* Modals */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(7, 9, 12, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 40;
}

.modal-card {
  width: min(420px, 92vw);
  background: rgba(16, 20, 28, 0.95);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 20px 22px;
  color: var(--paper);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.modal-header h2 {
  margin: 0;
  font-family: 'Fraunces', serif;
  font-size: 18px;
  font-weight: 600;
}

.modal-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.tab-btn {
  flex: 1;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--paper);
  padding: 6px 0;
  cursor: pointer;
}

.tab-btn.active {
  background: var(--amber);
  color: var(--ink);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.form-status {
  min-height: 18px;
  font-size: 12px;
  color: rgba(247, 241, 230, 0.7);
}

.forgot-link {
  background: none;
  border: none;
  padding: 0;
  font-size: 12px;
  color: var(--amber);
  cursor: pointer;
  opacity: 0.8;
  text-decoration: underline;
}

.forgot-link:hover {
  opacity: 1;
}

.record-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 420px;
  overflow-y: auto;
}

.record-item {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

@media (max-width: 980px) {
  .room-stage {
    min-height: 520px;
  }
}

@media (max-width: 600px) {
  html, body {
    overflow: hidden;
    height: 100%;
  }

  /* ── Game room: bottom-sheet panel, canvas fills top 70% ── */
  #room .room-panel {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 30vh;
    max-height: 30vh;
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
    border-top: 1px solid var(--border);
    padding: 6px 12px;
    gap: 4px;
    overflow-y: auto;
    z-index: 20;
  }

  #room .room-stage {
    height: 70vh;
  }

  /* Place-stone button floats over the canvas, just above the bottom panel
     (which is 30vh tall), so it's always visible during play — more
     discoverable than being buried in the panel menu.
     NOTE: .primary-btn has transform: translateY(-1px) on :hover which was
     overriding our translateX(-50%), causing the button to slide on tap
     and making the tap-target miss its rendered position. We force the
     transform + disable the transition on mobile to kill that. */
  .mobile-confirm-btn,
  .mobile-confirm-btn:hover,
  .mobile-confirm-btn:active,
  .mobile-confirm-btn:focus,
  .mobile-confirm-btn:focus-visible {
    position: fixed !important;
    bottom: calc(30vh + 12px);
    left: 50%;
    transform: translateX(-50%) !important;
    transition: none !important;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    animation: none !important;
    width: auto;
    min-width: 160px;
    padding: 14px 28px;
    font-size: 15px;
    font-weight: 700;
    margin: 0;
    /* z-index 35: above room-panel (20) and starDominationMenu (30) but
       BELOW the rules modal (40) so it doesn't obscure the dialog. */
    z-index: 35;
    border-radius: 999px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45),
                0 3px 12px rgba(242, 183, 5, 0.5);
  }

  /* Compact panel elements */
  #room .panel-section-title {
    font-size: 11px;
    margin: 4px 0 4px;
  }

  #room .panel-btn {
    padding: 8px 10px;
    font-size: 12px;
  }

  #room .panel-info {
    font-size: 11px;
    margin: 2px 0;
  }

  #room .room-info-block,
  #room .room-actions-block {
    padding-bottom: 6px;
    margin-bottom: 6px;
  }

  #room .small-log {
    height: 50px;
    min-height: 50px;
    max-height: 50px;
  }

  #room .panel-buttons {
    gap: 4px;
  }

  body {
    background-size: 50% auto, 100% auto;
    background-repeat: no-repeat, no-repeat;
    background-position: center 4%, top center;
  }

  .auth-corner {
    top: 10px;
    left: 10px;
    gap: 6px;
    max-width: calc(100vw - 20px);
  }

  .ghost-btn,
  .primary-btn {
    padding: 5px 10px;
    font-size: 11px;
  }

  .lobby-grid {
    position: fixed;
    /* image height = 100vw × (768/1344) */
    top: calc(100vw * 768 / 1344);
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    padding: 0;
    gap: 0;
    flex-direction: column;
    background: var(--ink);
  }

  .lobby-grid .panel {
    background: rgba(16, 20, 28, 0.95);
    backdrop-filter: none;
    border-radius: 0;
    border-left: none;
    border-right: none;
    box-shadow: none;
    padding: 8px 12px;
  }

  .lobby-grid .panel + .panel {
    border-top: 1px solid var(--border);
  }

  /* Chat is shorter; the side panel (online players + game rooms) takes the
     larger share of the lobby's vertical space. */
  .chat-panel {
    flex: 0 0 38%;
    min-height: 0;
    max-height: 38%;
  }

  .side-panel {
    flex: 1 1 62%;
    min-height: 0;
    max-height: 62%;
    gap: 8px;
  }

  .lobby-grid .panel-header {
    margin-bottom: 6px;
  }

  .lobby-grid .panel-block h3,
  .lobby-grid .panel-header h3 {
    font-size: 12px;
    margin-bottom: 4px;
  }

  .lobby-grid .chat-input {
    margin-top: 6px;
    gap: 6px;
  }

  .lobby-grid .chat-log {
    padding: 8px;
  }
}
