:root {
  color-scheme: dark;
  --bg: #08101c;
  --panel: rgba(18, 30, 44, 0.82);
  --panel-strong: rgba(22, 38, 62, 0.95);
  --border: rgba(255, 255, 255, 0.08);
  --text: #f5f9ff;
  --muted: #a3b1ce;
  --accent: #6ce0ff;
  --accent-strong: #52d7ff;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.32);
  --radius: 28px;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top, rgba(108, 224, 255, 0.12), transparent 30%),
              linear-gradient(180deg, #050b12 0%, #08101c 48%, #02060a 100%);
  color: var(--text);
}

button, select {
  font: inherit;
}

.app-shell {
  min-height: 100svh;
  padding: clamp(12px, 2vh, 24px);
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  gap: clamp(12px, 2vh, 24px);
  max-width: 1600px;
  margin: 0 auto;
}

.toolbar {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  align-items: center;
  padding: clamp(14px, 2vh, 24px);
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255,255,255,.08), rgba(255,255,255,0.04));
  backdrop-filter: blur(24px);
  align-content: start;
  align-self: start;
  position: sticky;
  top: clamp(12px, 2vh, 24px);
  max-height: calc(100svh - 24px);
  overflow-y: auto;
  scrollbar-gutter: stable;
}

.mobile-menu-toggle { display: none; }

.toolbar__brand {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.eyebrow {
  margin: 0;
  color: var(--accent-strong);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 0.78rem;
}

.toolbar__brand h1 {
  margin: 0;
  font-size: clamp(1.6rem, 2vw, 2.4rem);
}

.toolbar__status {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  flex-wrap: wrap;
}

.stat {
  min-width: 0;
  text-align: center;
}

.stat span {
  display: block;
  font-size: 1.2rem;
  font-weight: 700;
}

.stat small {
  color: var(--muted);
}

.toolbar__controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.field {
  display: grid;
  gap: 8px;
  color: var(--muted);
}

.field span {
  font-size: 0.85rem;
}

select,
.button {
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 14px;
  padding: 12px 16px;
  background: rgba(255,255,255,0.04);
  color: var(--text);
  cursor: pointer;
  transition: transform 180ms ease, background-color 180ms ease, box-shadow 180ms ease;
}

select option {
  background-color: #000;
  color: #fff;
}

.button:hover,
select:hover {
  transform: translateY(-1px);
}

.button:active {
  transform: translateY(0);
}

.button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.button--accent {
  background: linear-gradient(135deg, #4cc8ff, #6ce0ff);
  color: #05131f;
}

.button--secondary {
  background: rgba(255,255,255,0.08);
}

.game-area {
  display: grid;
  gap: 24px;
}

.panel {
  padding: clamp(14px, 2vh, 24px);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.board-panel {
  min-height: 0;
  position: relative;
}

.board-header {
  margin-bottom: 18px;
  position: relative;
}

.board-fullscreen-button { display: none; }

.board-header h2 {
  margin: 0 0 8px;
}

.board-title {
  --image-hue-primary: 195;
  --image-hue-secondary: 225;
  width: fit-content;
  color: hsl(var(--image-hue-primary) 88% 72%);
  background: linear-gradient(100deg,
    hsl(var(--image-hue-primary) 88% 72%),
    hsl(var(--image-hue-secondary) 84% 64%));
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  transition: --image-hue-primary 1100ms ease, --image-hue-secondary 1100ms ease,
              color 1100ms ease;
}

.board-wrap {
  position: relative;
  max-width: 1040px;
  margin: 0 auto;
}

.board {
  width: min(100%, calc(100svh - 140px), 1000px);
  max-width: 1000px;
  aspect-ratio: 1 / 1;
  border-radius: 32px;
  overflow: hidden;
  display: grid;
  grid-template-columns: repeat(var(--grid-size), 1fr);
  grid-auto-rows: 1fr;
  gap: 5px;
  background: radial-gradient(circle at top left, rgba(108,224,255,0.16), transparent 25%),
              rgba(9, 17, 28, 0.8);
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: inset 0 0 40px rgba(255,255,255,0.03);
  padding: 5px;
  position: relative;
  transition: gap 650ms ease, padding 650ms ease, box-shadow 300ms ease;
}

.tile {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: var(--tile-radius, 18px);
  border: 1px solid rgba(255,255,255,0.12);
  background-repeat: no-repeat;
  background-size: calc(var(--grid-size) * 100%) calc(var(--grid-size) * 100%);
  transition: transform 220ms cubic-bezier(0.22, 1, 0.36, 1),
              box-shadow 180ms ease,
              border-color 650ms ease,
              border-radius 650ms ease;
  transform: translate3d(var(--drag-x, 0), var(--drag-y, 0), 0) scale(var(--tile-scale, 1));
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.45), inset 0 2px 1px rgba(255,255,255,0.08);
  cursor: grab;
  display: grid;
  overflow: hidden;
  background-color: rgba(8,13,24,0.56);
}

@property --image-hue-primary {
  syntax: '<number>';
  inherits: false;
  initial-value: 205;
}

@property --image-hue-secondary {
  syntax: '<number>';
  inherits: false;
  initial-value: 225;
}

.change-image-button {
  --image-hue-primary: 205;
  --image-hue-secondary: 225;
  position: absolute;
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid hsl(var(--image-hue-primary) 90% 88% / 0.55);
  border-radius: 50%;
  background: linear-gradient(135deg,
    hsl(var(--image-hue-primary) 88% 72%),
    hsl(var(--image-hue-secondary) 78% 48%));
  color: hsl(var(--image-hue-primary) 55% 9%);
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  transform: translateY(-50%);
  box-shadow: 0 12px 30px hsl(var(--image-hue-primary) 85% 55% / 0.42), inset 0 1px 1px rgba(255, 255, 255, 0.55);
  transition: --image-hue-primary 1100ms ease, --image-hue-secondary 1100ms ease, transform 180ms ease,
              box-shadow 800ms ease, border-color 800ms ease, color 800ms ease, filter 180ms ease;
  z-index: 6;
}

.change-image-button:hover {
  transform: translateY(-50%) scale(1.08);
  filter: brightness(1.08);
  box-shadow: 0 16px 38px hsl(var(--image-hue-primary) 90% 55% / 0.55), inset 0 1px 1px rgba(255, 255, 255, 0.65);
}

.change-image-button:active {
  transform: translateY(-50%) scale(0.98);
}

.change-image-button:disabled {
  opacity: 0.45;
  cursor: wait;
}

.tile-face {
  position: absolute;
  inset: 0;
  display: block;
  border-radius: inherit;
  background-repeat: no-repeat;
  backface-visibility: hidden;
  pointer-events: none;
}

.tile-face--front {
  transform: translateZ(var(--cube-depth, 0));
}

.tile-face--right {
  transform: rotateY(90deg) translateZ(var(--cube-depth, 0));
}

.board--cube-turn {
  perspective: 1200px;
}

.board--cube-turn .tile,
.board--cube-turn .tile:hover {
  overflow: visible;
  pointer-events: none;
  transform-style: preserve-3d;
  transform: perspective(1000px) rotateY(-90deg);
  box-shadow: 20px 4px 32px rgba(0, 0, 0, 0.42);
  transition: transform 520ms cubic-bezier(0.65, 0, 0.35, 1) var(--tile-delay, 0ms),
              box-shadow 520ms ease var(--tile-delay, 0ms);
}
.board--preview .tile,
.board--preview .tile:hover {
  border-radius: 0;
  border-color: transparent;
  box-shadow: none;
  pointer-events: none;
  transform: translate3d(var(--preview-x, 0), var(--preview-y, 0), 0);
  transition: transform 300ms cubic-bezier(0.22, 1, 0.36, 1),
              border-radius 300ms ease,
              box-shadow 300ms ease;
}

.board--shuffling .tile,
.board--shuffling .tile:hover {
  z-index: 2;
  pointer-events: none;
  transform: translate3d(var(--shuffle-x, 0), var(--shuffle-y, 0), 0)
             rotate(var(--shuffle-rotate, 0deg)) scale(0.96);
  box-shadow: 0 24px 42px rgba(0, 0, 0, 0.42);
  transition: transform 900ms cubic-bezier(0.22, 1, 0.36, 1),
              box-shadow 450ms ease,
              border-radius 450ms ease;
}
.board--solved {
  animation: victoryGlow 2.4s ease-in-out 650ms;
}

.board--solved .tile,
.board--solved .tile:hover {
  border-radius: 0;
  border-color: transparent;
  box-shadow: none;
  cursor: default;
  pointer-events: none;
  transform: translate3d(var(--solve-x, 0), var(--solve-y, 0), 0);
  transition: transform 800ms cubic-bezier(0.22, 1, 0.36, 1),
              border-radius 800ms ease,
              border-color 800ms ease,
              box-shadow 800ms ease;
}

@keyframes victoryGlow {
  0%, 100% { box-shadow: 0 0 0 rgba(108, 224, 255, 0); }
  25% { box-shadow: 0 0 18px #6ce0ff, 0 0 42px rgba(108, 224, 255, 0.75); }
  55% { box-shadow: 0 0 22px #fff4a8, 0 0 54px rgba(255, 220, 100, 0.7); }
  80% { box-shadow: 0 0 18px #8cffbd, 0 0 42px rgba(53, 232, 121, 0.65); }
}

.tile::before {
  z-index: 3;
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(circle at top left, rgba(255,255,255,0.12), transparent 35%);
  opacity: 0.14;
  pointer-events: none;
}
.tile:hover {
  transform: translate3d(var(--drag-x, 0), var(--drag-y, 0), 0) scale(1.03);
}

.tile--dragging {
  z-index: 10;
  box-shadow: 0 36px 72px rgba(0, 0, 0, 0.45);
  border-color: rgba(108,224,255,0.7);
}

.tile:hover {
  transform: translate3d(var(--drag-x, 0), var(--drag-y, 0), 0) scale(1.015);
}

.tile--dragging {
  z-index: 10;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.38);
  border-color: rgba(108,224,255,0.55);
}

.tile--correct {
  box-shadow: inset 0 0 0 1px rgba(108,224,255,0.18), 0 14px 36px rgba(0, 0, 0, 0.3);
  border-color: rgba(108,224,255,0.35);
}

.tile--clued {
  border: 3px solid #35e879;
  box-shadow: inset 0 0 0 2px rgba(53, 232, 121, 0.35), 0 0 18px rgba(53, 232, 121, 0.4);
  cursor: default;
}
.victory-message {
  position: absolute;
  width: 220px;
  transform: translateY(-50%);
  border-radius: 28px;
  background: rgba(2, 9, 18, 0.96);
  border: 1px solid rgba(108,224,255,0.15);
  display: grid;
  place-items: center;
  gap: 16px;
  text-align: center;
  padding: 24px;
  z-index: 5;
}


.victory-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
}

.victory-stats div,
.victory-stats span {
  display: block;
}

.victory-stats div {
  padding: 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
}

.victory-stats strong {
  font-size: 1.25rem;
}

.victory-stats span {
  color: var(--muted);
  font-size: 0.8rem;
}
.hidden {
  display: none !important;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 8, 18, 0.82);
  display: grid;
  place-items: center;
  z-index: 100;
}

.overlay-card {
  padding: 32px;
  background: rgba(12, 21, 35, 0.95);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 28px;
  box-shadow: var(--shadow);
  text-align: center;
}

.confetti {
  position: fixed;
  top: -20px;
  pointer-events: none;
  opacity: 0.95;
  transform: translateY(0) rotate(15deg);
  animation: fallConfetti linear forwards;
}

@keyframes fallConfetti {
  to {
    transform: translateY(110vh) rotate(620deg);
    opacity: 0;
  }
}

@media (max-width: 1180px) {
  .board-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  .change-image-button {
    position: static;
    width: 58px;
    align-self: center;
    margin: 18px 0 0;
    transform: none;
  }

  .change-image-button:hover,
  .change-image-button:active {
    transform: scale(1.06);
  }  .victory-message {
    position: static;
    width: 100%;
    margin-top: 16px;
    transform: none;
  }
}
@media (min-width: 701px) and (max-width: 1180px) {
  html:not(.phone-layout) .app-shell {
    grid-template-columns: minmax(210px, 250px) minmax(0, 1fr);
    gap: 16px;
    padding: 16px;
  }

  html:not(.phone-layout) .toolbar,
  html:not(.phone-layout) .board-panel,
  html:not(.phone-layout) .opponent-panel { padding: 16px; }
}

@media (max-width: 980px) {
  html:not(.phone-layout) body { overflow-x: auto; }

  html:not(.phone-layout) .app-shell {
    min-width: 940px;
    grid-template-columns: minmax(210px, 250px) minmax(0, 1fr);
  }

  .phone-layout .app-shell {
    min-width: 0;
    grid-template-columns: 1fr;
  }

  .phone-layout .game-area {
    grid-template-columns: 1fr;
  }

  .phone-layout .toolbar {
    grid-template-columns: 1fr;
    position: static;
  }

  .phone-layout .toolbar__controls {
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  }

  .phone-layout .board {
    width: min(100%, 760px);
  }
}

@media (max-width: 680px) {
  .app-shell {
    padding: 16px;
  }

  .phone-layout .toolbar__controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .button,
  select {
    padding: 9px 10px;
  }

  .board-header {
    margin-bottom: 10px;
  }

  .board-header p {
    margin-bottom: 0;
  }

  .sample-list {
    grid-template-columns: 1fr 1fr;
  }

  .tile {
    border-radius: var(--tile-radius, 14px);
  }
}

.button--online {
  background: linear-gradient(135deg, #8cffbd, #4cc8ff);
  color: #04131b;
  font-weight: 700;
}

.online-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at top, rgba(76, 200, 255, 0.18), transparent 38%), rgba(2, 7, 14, 0.94);
  backdrop-filter: blur(18px);
}

.online-shell {
  width: min(1080px, 100%);
  max-height: calc(100svh - 48px);
  overflow: auto;
  background: linear-gradient(145deg, rgba(20, 35, 55, 0.98), rgba(7, 15, 27, 0.98));
}

.online-header,
.section-heading,
.game-card,
.room-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.online-header h2,
.section-heading h3,
.game-card h4,
.alias-card h3,
.create-game-card h3,
.room-card h3 {
  margin: 0;
}

.icon-button {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 1.7rem;
  line-height: 1;
  cursor: pointer;
}

.icon-button span {
  transform: translateY(-3px);
}

.online-error {
  margin: 16px 0 0;
  padding: 12px 14px;
  border: 1px solid rgba(255, 112, 112, 0.35);
  border-radius: 12px;
  background: rgba(255, 80, 80, 0.1);
  color: #ffb5b5;
}

.online-announcement {
  margin: 16px 0 0;
  padding: 12px 14px;
  border: 1px solid rgba(123, 180, 255, 0.35);
  border-radius: 12px;
  background: rgba(70, 135, 230, 0.12);
  color: #d9eaff;
}
.online-view {
  margin-top: 22px;
}

.alias-card,
.room-card {
  max-width: 620px;
  margin: 40px auto;
  padding: 28px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.04);
  text-align: center;
}

#aliasForm {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-top: 22px;
}

input {
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font: inherit;
  outline: none;
}

input:focus {
  border-color: rgba(108, 224, 255, 0.7);
  box-shadow: 0 0 0 3px rgba(108, 224, 255, 0.1);
}

.lobby-grid {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 22px;
}

.lobby-players,
.create-game-card {
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.035);
}

.count-badge {
  min-width: 28px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(108, 224, 255, 0.14);
  color: var(--accent);
  text-align: center;
  font-size: 0.82rem;
}

.player-list,
.game-list,
.room-players {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.player-list {
  max-height: 300px;
  padding-right: 6px;
  overflow-y: auto;
  scrollbar-gutter: stable;
}

.alias-confirm {
  margin-top: 18px;
  padding: 16px;
  border: 1px solid rgba(255, 210, 110, 0.28);
  border-radius: 16px;
  background: rgba(255, 190, 70, 0.08);
  text-align: left;
}

.alias-confirm p { margin: 0; color: var(--muted); }

.alias-confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}

.game-list {
  max-height: 330px;
  padding-right: 6px;
  overflow-y: auto;
  scrollbar-gutter: stable;
}

.scroll-list--has-more::after {
  content: '\2193  More below';
  position: sticky;
  bottom: 0;
  display: block;
  padding: 8px;
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(8, 16, 28, 0.72), rgba(8, 16, 28, 0.98));
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 700;
  text-align: center;
  pointer-events: none;
}

.player-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 9px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.player-row small {
  color: var(--muted);
  font-size: 0.72rem;
}

.player-details {
  display: grid;
  justify-items: end;
  gap: 2px;
  white-space: nowrap;
}

.player-row .player-record {
  color: var(--accent);
  font-weight: 700;
}

.change-alias-button {
  width: 100%;
  margin-top: 14px;
}

.presence-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #45e78c;
  box-shadow: 0 0 10px rgba(69, 231, 140, 0.7);
}

.presence-dot--busy {
  background: #ffc766;
  box-shadow: 0 0 10px rgba(255, 199, 102, 0.6);
}

.presence-dot--away {
  background: #8390aa;
  box-shadow: 0 0 10px rgba(131, 144, 170, 0.45);
}

.create-game-card {
  margin: 22px 0 0;
}

.create-game-card summary {
  cursor: pointer;
  font-size: 1.05rem;
  font-weight: 700;
}

.create-game-form {
  display: grid;
  grid-template-columns: repeat(3, 1fr) auto;
  gap: 12px;
  align-items: end;
  margin-top: 16px;
}

.create-game-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.82rem;
}

.game-card {
  padding: 16px 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.025));
}

.game-card p,
.empty-state {
  margin: 6px 0 0;
  color: var(--muted);
}

.empty-state {
  padding: 32px;
  border: 1px dashed rgba(255, 255, 255, 0.12);
  border-radius: 18px;
  text-align: center;
}

.room-rules {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 24px 0;
}

.room-rules div {
  padding: 18px;
  border-radius: 18px;
  background: rgba(108, 224, 255, 0.08);
}

.room-rules strong,
.room-rules span,
.room-player span,
.room-player strong {
  display: block;
}

.room-rules strong {
  font-size: 1.35rem;
}

.room-rules span,
.room-player span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.8rem;
}

.room-player {
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  text-align: left;
}

.room-player--ready {
  border-color: rgba(53, 232, 121, 0.5);
  background: rgba(53, 232, 121, 0.08);
}

.room-player--ready::after {
  content: 'Ready';
  float: right;
  margin-top: -28px;
  color: #65efa0;
}

.room-status {
  min-height: 24px;
  color: var(--accent);
}

@media (max-width: 760px) {
  .online-overlay { padding: 0; }
  .online-shell { width: 100%; max-height: 100svh; min-height: 100svh; border-radius: 0; }
  .lobby-grid { grid-template-columns: 1fr; }
  .create-game-form, #aliasForm { grid-template-columns: 1fr; }
  .room-actions { flex-direction: column; }
  .room-actions .button { width: 100%; }
}
/* Online match */
.game-area:has(.online-match-bar:not(.hidden)) {
  grid-template-columns: minmax(0, 1fr) minmax(220px, 300px);
  align-items: center;
  gap: clamp(14px, 2vw, 24px);
}

.online-match-bar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 12px 18px;
  border: 1px solid rgba(108, 224, 255, 0.22);
  background: rgba(10, 24, 40, 0.9);
}

.online-match-bar span,
.opponent-heading span,
.opponent-moves span {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.opponent-heading span { white-space: nowrap; }

.online-match-bar strong,
.match-clock strong {
  display: block;
  margin-top: 2px;
  color: var(--accent);
}

.match-clock { text-align: center; }
.match-clock strong { font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.online-match-active .board-panel { grid-column: 1; }
.online-match-active .toolbar__status { display: none; }
.online-match-active #clueBtn,
.online-match-active #restartBtn,
.online-match-active #pauseBtn,
.online-match-active #changeImageBtn,
.online-match-active #sizePicker { opacity: 0.45; cursor: not-allowed; }

.opponent-panel {
  grid-column: 2;
  width: 100%;
  padding: 18px;
  border: 1px solid rgba(108, 224, 255, 0.16);
}

.opponents-container {
  display: grid;
  gap: 14px;
}

.opponent-card {
  position: relative;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
  transition: box-shadow 350ms ease, border-color 350ms ease;
}

.opponent-card:last-child { padding-bottom: 0; border-bottom: 0; }
.opponent-card > p { margin: 7px 0 0; color: var(--muted); font-size: 0.76rem; }


.opponent-connection {
  display: inline-block;
  width: 9px;
  height: 9px;
  margin: 0 !important;
  margin-left: 6px !important;
  border-radius: 999px;
  cursor: help;
  vertical-align: 1px;
  background: #8fa5bc;
  box-shadow: 0 0 8px rgba(143, 165, 188, 0.55);
}

.opponent-card--connected { border-color: rgba(101, 239, 160, 0.78); }
.opponent-card--disconnected { border-color: rgba(255, 199, 102, 0.78); }
.opponent-card--left { border-color: rgba(143, 165, 188, 0.7); }
.opponent-connection--connected { background: #65efa0; box-shadow: 0 0 11px rgba(101, 239, 160, 1); }
.opponent-connection--disconnected { background: #ffc766; box-shadow: 0 0 11px rgba(255, 199, 102, 1); }
.opponent-connection--left { background: #8fa5bc; box-shadow: 0 0 11px rgba(143, 165, 188, 0.85); }
.opponent-card--left .opponent-grid { opacity: 0.48; }
.opponent-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.opponent-heading h2 { margin: 2px 0 0; font-size: 1.05rem; }
.opponent-label { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.opponent-moves { text-align: right; }
.opponent-moves strong { display: block; color: var(--accent); font-size: 1.15rem; }

.opponent-grid {
  --opponent-size: 4;
  display: grid;
  grid-template-columns: repeat(var(--opponent-size), 1fr);
  gap: clamp(2px, 0.35vw, 5px);
  width: min(100%, 185px);
  aspect-ratio: 1;
  margin: 8px auto 0;
  padding: 6px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  background: rgba(2, 8, 16, 0.72);
}

.opponent-cell {
  min-width: 0;
  min-height: 0;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: clamp(2px, calc(12px - var(--opponent-size) * 0.8px), 8px);
  background: rgba(255, 255, 255, 0.035);
  transition: background 350ms ease, box-shadow 350ms ease, border-color 350ms ease;
}

.opponent-cell--correct {
  border-color: rgba(104, 205, 255, 0.95);
  background: linear-gradient(145deg, #37a9ef, #1673ce);
  box-shadow: 0 0 12px rgba(71, 181, 255, 0.48), inset 0 0 8px rgba(255, 255, 255, 0.2);
}

.online-match-finished .board { pointer-events: none; }

@media (max-width: 1050px) {
  .game-area:has(.online-match-bar:not(.hidden)) { grid-template-columns: minmax(0, 1fr) minmax(180px, 230px); }
}

@media (max-width: 760px) {
  .game-area:has(.online-match-bar:not(.hidden)) { grid-template-columns: 1fr; }
  .online-match-active .board-panel, .opponent-panel { grid-column: 1; }
  .opponent-panel { max-width: 340px; margin: 0 auto; }
  .online-match-bar { flex-wrap: wrap; }
}
.online-match-active .board { width: min(100%, calc(100svh - 230px), 1000px); }

.match-summary {
  display: grid;
  gap: 4px;
}

.match-score {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 7px;
}

.match-score__player {
  display: grid;
  grid-template-columns: minmax(45px, auto) auto;
  align-items: center;
  gap: 7px;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(108, 224, 255, 0.1);
  overflow: hidden;
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.match-score__player small { overflow: hidden; text-overflow: ellipsis; }
.match-score__player strong {
  color: var(--accent);
  font-size: 1.1rem;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.opponent-result {
  padding: 10px 12px;
  border: 1px solid rgba(94, 194, 255, 0.45);
  border-radius: 12px;
  background: rgba(40, 149, 230, 0.14);
  color: #82d6ff !important;
  font-weight: 800;
  text-align: center;
}

.opponent-card--winner {
  border-color: rgba(79, 190, 255, 0.75);
  box-shadow: 0 0 30px rgba(55, 169, 239, 0.3), inset 0 0 24px rgba(55, 169, 239, 0.08);
  animation: opponentWinnerPulse 1.1s ease-in-out 2;
}

.opponent-card--winner .opponent-grid {
  border-color: rgba(104, 205, 255, 0.8);
  box-shadow: 0 0 24px rgba(71, 181, 255, 0.35);
}

.rematch-panel {
  display: grid;
  gap: 8px;
  margin: 14px 0;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.045);
  text-align: center;
}
.rematch-panel > span { color: var(--muted); font-size: 0.82rem; }
.rematch-panel > div { display: flex; justify-content: center; gap: 8px; }
.online-result-overlay {
  position: absolute;
  inset: 50% auto auto 50%;
  z-index: 85;
  width: min(340px, calc(100% - 32px));
  margin: 0;
  padding: 22px;
  transform: translate(-50%, -50%);
  border-color: rgba(108, 224, 255, 0.34);
  background: rgba(2, 9, 18, 0.42);
  box-shadow: 0 18px 55px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(5px);
}
.online-result-overlay > .victory-stats { display: grid; }
.online-match-active .victory-message { display: none !important; }
.online-match-active .fullscreen-rematch-panel { display: none !important; }
.online-match-active #celebrateBtn { display: none; }

@keyframes opponentWinnerPulse {
  50% { transform: translateY(-2px); box-shadow: 0 0 45px rgba(55, 169, 239, 0.5), inset 0 0 28px rgba(55, 169, 239, 0.12); }
}

@media (max-width: 760px) {
  .match-score { grid-template-columns: minmax(60px, 1fr) auto minmax(60px, 1fr); }
}
.online-match-active #changeImageBtn { display: none !important; }

/* Phone-only enhancements. Desktop remains the unmodified default layout. */
.phone-layout { -webkit-text-size-adjust: 100%; }
.phone-layout body { min-height: 100dvh; overscroll-behavior-y: contain; }
.phone-layout .board {
  touch-action: none;
  transform: translate3d(var(--phone-board-x, 0), var(--phone-board-y, 0), 0)
             scale(var(--phone-board-scale, 1));
  transform-origin: center;
  transition: gap 650ms ease, padding 650ms ease, box-shadow 300ms ease, transform 120ms ease-out;
  will-change: transform;
}
.phone-layout .board.board--gesturing { transition: none; }
.phone-layout .board.board--zoomed {
  z-index: 30;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.65), inset 0 0 40px rgba(255, 255, 255, 0.03);
}
.phone-layout .board--zoomed .tile { cursor: grab; }
.phone-layout .board--zoomed .tile--dragging { cursor: grabbing; }
.phone-layout .tile {
  cursor: default;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.phone-layout .button,
.phone-layout select,
.phone-layout input,
.phone-layout .icon-button,
.phone-layout .change-image-button { min-height: 44px; }
.phone-layout .game-card--unsupported { opacity: 0.72; }

@media (max-width: 700px) {
  .phone-layout body.mobile-online-mode .toolbar { display: none; }
  .phone-layout .app-shell {
    min-height: 100dvh;
    padding: 10px;
    gap: 10px;
  }
  .phone-layout .panel { padding: 12px; border-radius: 18px; }
  .phone-layout .toolbar { gap: 0; }
  .phone-layout .mobile-menu-toggle { margin-bottom: 12px; }
  .phone-layout .mobile-menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    width: 100%;
    min-height: 44px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
  }
  .phone-layout .mobile-menu-toggle__icon {
    width: 10px;
    height: 10px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(225deg) translate(-1px, -1px);
    transition: transform 240ms ease;
  }
  .phone-layout.mobile-menu-collapsed .mobile-menu-toggle__icon {
    transform: rotate(45deg) translate(-1px, -1px);
  }
  .phone-layout .toolbar__brand,
  .phone-layout .toolbar__controls {
    overflow: hidden;
    opacity: 1;
    transform: translateY(0);
    transition: max-height 260ms ease, opacity 180ms ease, transform 260ms ease;
  }
  .phone-layout .toolbar__brand { max-height: 90px; margin-bottom: 12px; }
  .phone-layout .toolbar__status { margin-bottom: 12px; }
  .phone-layout .toolbar__controls { max-height: 440px; }
  .phone-layout.mobile-menu-collapsed .toolbar__brand,
  .phone-layout.mobile-menu-collapsed .toolbar__controls {
    max-height: 0;
    opacity: 0;
    transform: translateY(-8px);
    margin-bottom: 0;
    pointer-events: none;
  }
  .phone-layout.mobile-menu-collapsed .toolbar__status { margin-bottom: 0; }
  .phone-layout .toolbar__brand h1 { font-size: 1.45rem; }
  .phone-layout .toolbar__status {
    position: sticky;
    top: 0;
    z-index: 20;
    padding: 8px;
    border-radius: 14px;
    background: rgba(8, 16, 28, 0.94);
    backdrop-filter: blur(14px);
  }
  .phone-layout .toolbar__controls { gap: 8px; }
  .phone-layout .field { grid-column: 1 / -1; }
  .phone-layout .game-area { gap: 10px; }
  .phone-layout .board-header h2 { font-size: 1.1rem; }
  .phone-layout .board-header p { font-size: 0.82rem; }
  .phone-layout .board-header { padding-right: 50px; }
  .phone-layout .board-fullscreen-button {
    position: absolute;
    top: 0;
    right: 0;
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.07);
    color: var(--accent);
    font-size: 1.35rem;
  }  .phone-layout .board {
    width: 100%;
    max-width: calc(100dvw - 44px);
    gap: 3px;
    padding: 3px;
    border-radius: 18px;
  }
  .phone-layout .change-image-button {
    width: 52px;
    height: 52px;
    margin-top: 12px;
  }
  .phone-layout .online-overlay { height: 100dvh; }
  .phone-layout .online-shell {
    min-height: 100dvh;
    max-height: 100dvh;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }
  .phone-layout .online-announcement {
  margin: 16px 0 0;
  padding: 12px 14px;
  border: 1px solid rgba(123, 180, 255, 0.35);
  border-radius: 12px;
  background: rgba(70, 135, 230, 0.12);
  color: #d9eaff;
}
.online-view { margin-top: 14px; }
  .phone-layout .alias-card,
  .phone-layout .room-card { margin: 18px auto; padding: 16px; }
  .phone-layout .lobby-grid { gap: 14px; }
  .phone-layout .lobby-players,
  .phone-layout .create-game-card { padding: 14px; }
  .phone-layout .game-card { align-items: stretch; flex-direction: column; }
  .phone-layout .game-card .button { width: 100%; }
  .phone-layout .online-match-bar {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
  }
  .phone-layout .online-match-bar .match-summary { grid-column: 1 / -1; }
  .phone-layout .match-score {
    max-width: 100%;
    overflow-x: auto;
    padding-bottom: 3px;
  }
  .phone-layout .online-match-active .board {
    width: 100%;
    max-width: calc(100dvw - 44px);
  }
  .phone-layout .opponent-panel { max-width: none; }
  .phone-layout .opponents-container {
    grid-template-columns: repeat(auto-fit, minmax(135px, 1fr));
  }
  .phone-layout .opponent-card {
    padding: 10px;
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 14px;
  }
  .phone-layout .opponent-grid { width: min(100%, 145px); }
}

@media (orientation: landscape) and (max-height: 500px) {
  .phone-layout .app-shell {
    grid-template-columns: minmax(180px, 30vw) minmax(0, 1fr);
    align-items: start;
  }
  .phone-layout .toolbar { position: sticky; top: 8px; }
  .phone-layout .toolbar__brand { display: none; }
  .phone-layout .board {
    width: min(calc(100dvh - 20px), 100%);
    max-width: none;
  }
  .phone-layout body:not(.online-match-active) .change-image-button {
    position: absolute;
    right: 8px;
    top: 50%;
    bottom: auto;
    margin: 0;
    transform: translateY(-50%);
  }
}
/* Mobile puzzle fullscreen: the 1x view always contains the complete square board. */
.fullscreen-hud,
.fullscreen-exit-button,
.fullscreen-opponent-panel { display: none; }

.phone-layout .online-match-active .board-wrap:fullscreen .fullscreen-opponent-panel,
.phone-layout body.online-match-active.mobile-board-fullscreen .fullscreen-opponent-panel {
  position: relative;
  grid-area: 2 / 1;
  z-index: 82;
  display: grid;
  width: min(calc(100dvw - 20px), 340px);
  margin: 12px auto max(10px, env(safe-area-inset-bottom));
  padding: 10px;
  border: 1px solid rgba(108, 224, 255, 0.3);
  border-radius: 16px;
  background: rgba(2, 8, 16, 0.76);
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(10px);
}

.fullscreen-opponent-toggle {
  min-height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font: 700 0.76rem/1 system-ui, sans-serif;
}

.phone-layout .fullscreen-opponent-toggle { display: none; }

.fullscreen-opponents-container { display: grid; gap: 8px; margin-top: 8px; }
.fullscreen-opponent-panel .opponent-card { padding-bottom: 8px; }
.fullscreen-opponent-panel .opponent-heading h2 { font-size: 0.88rem; }
.fullscreen-opponent-panel .opponent-heading span,
.fullscreen-opponent-panel .opponent-moves span { font-size: 0.6rem; }
.fullscreen-opponent-panel .opponent-grid { width: min(100%, 116px); padding: 4px; gap: 2px; }
.fullscreen-opponent-panel--compact { width: min(calc(100dvw - 20px), 220px) !important; }
.fullscreen-opponent-panel--compact .opponent-grid,
.fullscreen-opponent-panel--compact .opponent-moves { display: none; }
.fullscreen-opponent-panel--compact .opponent-card > p {
  margin-top: 4px;
  color: var(--accent);
  font-weight: 700;
}

.phone-layout .board-wrap:fullscreen,
.phone-layout body.mobile-board-fullscreen .board-wrap {
  width: 100%;
  height: 100%;
  max-width: none;
  margin: 0;
  padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right))
           max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  display: grid;
  place-items: center;
  overflow-x: hidden;
  overflow-y: auto;
  background: radial-gradient(circle at center, rgba(108, 224, 255, 0.11), transparent 55%), #02060a;
}

.phone-layout body.mobile-board-fullscreen {
  overflow: hidden;
}

.phone-layout body.mobile-board-fullscreen .board-wrap {
  position: fixed;
  inset: 0;
  z-index: 500;
  width: 100dvw;
  height: 100dvh;
}

.phone-layout .board-wrap:fullscreen .board,
.phone-layout body.mobile-board-fullscreen .board-wrap .board {
  grid-area: 1 / 1;
  width: min(calc(100dvw - 16px), calc(100dvh - 16px));
  max-width: none;
  max-height: none;
  margin: 0;
  border-radius: clamp(8px, 2.5vmin, 22px);
}

.phone-layout .board-wrap:fullscreen .fullscreen-hud,
.phone-layout body.mobile-board-fullscreen .fullscreen-hud {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  left: max(10px, env(safe-area-inset-left));
  z-index: 80;
  display: flex;
  gap: 8px;
  pointer-events: none;
}

.phone-layout .fullscreen-hud span {
  padding: 7px 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: rgba(2, 8, 16, 0.7);
  color: var(--muted);
  font-size: 0.72rem;
  backdrop-filter: blur(12px);
}

.phone-layout .fullscreen-hud strong {
  margin-right: 3px;
  color: var(--accent);
  font-size: 0.9rem;
}

.phone-layout .board-wrap:fullscreen .fullscreen-exit-button,
.phone-layout body.mobile-board-fullscreen .fullscreen-exit-button {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  right: max(10px, env(safe-area-inset-right));
  z-index: 90;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  background: rgba(2, 8, 16, 0.68);
  color: #fff;
  font: 400 1.7rem/1 system-ui, sans-serif;
  backdrop-filter: blur(12px);
}

.phone-layout .board-wrap:fullscreen .change-image-button,
.phone-layout body.mobile-board-fullscreen .board-wrap .change-image-button {
  display: none !important;
}

.phone-layout .board-wrap:fullscreen .victory-message,
.phone-layout body.mobile-board-fullscreen .board-wrap .victory-message {
  position: absolute;
  inset: 50% auto auto 50%;
  z-index: 85;
  width: min(300px, calc(100dvw - 32px));
  max-height: calc(100dvh - 32px);
  margin: 0;
  padding: clamp(14px, 3vmin, 22px);
  gap: 10px;
  overflow-y: auto;
  transform: translate(-50%, -50%);
  border-color: rgba(108, 224, 255, 0.32);
  background: rgba(2, 9, 18, 0.58);
  box-shadow: 0 18px 55px rgba(0, 0, 0, 0.38);
  backdrop-filter: blur(4px);
}
@media (orientation: landscape) and (max-width: 1000px) {
  .phone-layout .online-match-active .board-wrap:fullscreen,
  .phone-layout body.online-match-active.mobile-board-fullscreen .board-wrap {
    grid-template-columns: 60px minmax(0, 1fr) minmax(140px, 26dvw);
    grid-template-rows: auto 1fr;
    gap: 8px;
    overflow: hidden;
  }

  .phone-layout .online-match-active .board-wrap:fullscreen .board,
  .phone-layout body.online-match-active.mobile-board-fullscreen .board-wrap .board {
    grid-area: 1 / 2 / 3 / 3;
    width: min(calc(100dvh - 16px), calc(74dvw - 80px));
  }

  .phone-layout .online-match-active .board-wrap:fullscreen .fullscreen-opponent-panel,
  .phone-layout body.online-match-active.mobile-board-fullscreen .fullscreen-opponent-panel {
    grid-area: 1 / 3 / 3 / 4;
    width: 100%;
    max-height: calc(100dvh - 20px);
    margin: 0;
    overflow-y: auto;
  }

  .phone-layout .fullscreen-opponent-panel--compact { width: 100% !important; }

  .phone-layout .online-match-active .board-wrap:fullscreen .fullscreen-exit-button,
  .phone-layout body.online-match-active.mobile-board-fullscreen .fullscreen-exit-button {
    position: static;
    grid-area: 1 / 1;
    align-self: start;
    justify-self: center;
  }

  .phone-layout .online-match-active .board-wrap:fullscreen .fullscreen-hud,
  .phone-layout body.online-match-active.mobile-board-fullscreen .fullscreen-hud {
    position: static;
    grid-area: 2 / 1;
    align-self: start;
    justify-self: center;
    flex-direction: column;
  }

  .phone-layout .online-match-active .fullscreen-hud span {
    width: 54px;
    padding: 6px 2px;
    font-size: 0.58rem;
    text-align: center;
  }

  .phone-layout .online-match-active .fullscreen-hud strong {
    display: block;
    margin: 0 0 2px;
    font-size: 0.82rem;
  }
  .phone-layout .fullscreen-hud span:nth-child(1) { order: 2; }
  .phone-layout .fullscreen-hud span:nth-child(2) { order: 1; }
}
@media (orientation: portrait) and (max-width: 700px) {
  .phone-layout body:not(.online-match-active) .board-wrap:fullscreen,
  .phone-layout body:not(.online-match-active).mobile-board-fullscreen .board-wrap {
    grid-template-rows: auto auto auto auto;
    grid-template-areas: "status exit" "board board" "change change" "opponent opponent";
  }

  .phone-layout body:not(.online-match-active) .board-wrap:fullscreen .change-image-button,
  .phone-layout body:not(.online-match-active).mobile-board-fullscreen .board-wrap .change-image-button {
    position: static;
    grid-area: change;
    display: grid !important;
    width: 52px;
    height: 52px;
    margin: 0 auto;
    transform: none;
  }

  .phone-layout .board-header {
    min-height: 40px;
    display: flex;
    align-items: center;
  }
}
@media (orientation: landscape) and (max-width: 1000px) {
  .phone-layout body:not(.online-match-active) .board-wrap:fullscreen,
  .phone-layout body:not(.online-match-active).mobile-board-fullscreen .board-wrap {
    grid-template-columns: 60px minmax(0, 1fr) 60px;
    grid-template-rows: 1fr;
    grid-template-areas: "hud board change";
    gap: 8px;
    overflow: hidden;
  }

  .phone-layout body:not(.online-match-active) .board-wrap:fullscreen .board,
  .phone-layout body:not(.online-match-active).mobile-board-fullscreen .board-wrap .board {
    grid-area: 1 / 2;
    width: min(calc(100dvh - 16px), calc(100dvw - 136px));
  }

  .phone-layout body:not(.online-match-active) .board-wrap:fullscreen .change-image-button,
  .phone-layout body:not(.online-match-active).mobile-board-fullscreen .board-wrap .change-image-button {
    position: static;
    grid-area: change;
    display: grid !important;
    align-self: center;
    justify-self: center;
    width: 52px;
    height: 52px;
    margin: 0;
    transform: none;
  }

  .phone-layout body:not(.online-match-active) .board-wrap:fullscreen .fullscreen-hud,
  .phone-layout body:not(.online-match-active).mobile-board-fullscreen .fullscreen-hud {
    position: static;
    grid-area: 1 / 1;
    align-self: center;
    justify-self: center;
    flex-direction: column;
  }
}
@media (orientation: portrait) and (max-width: 700px) {
  .phone-layout body.mobile-online-mode.online-match-active .online-match-bar {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    align-items: center;
  }

  .phone-layout body.mobile-online-mode.online-match-active .online-match-bar .match-summary {
    grid-column: 1;
    grid-row: 1 / 3;
  }

  .phone-layout body.mobile-online-mode.online-match-active .match-clock {
    grid-column: 2;
    grid-row: 1;
  }

  .phone-layout body.mobile-online-mode.online-match-active #leaveMatchBtn {
    grid-column: 2;
    grid-row: 2;
    padding: 7px 10px;
  }
  .phone-layout .board-wrap:fullscreen,
  .phone-layout body.mobile-board-fullscreen .board-wrap {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto auto;
    grid-template-areas: "status exit" "board board" "opponent opponent";
    align-content: start;
    gap: 8px;
  }

  .phone-layout .board-wrap:fullscreen .fullscreen-hud,
  .phone-layout body.mobile-board-fullscreen .fullscreen-hud {
    position: static;
    grid-area: status;
    align-self: center;
    justify-self: start;
  }

  .phone-layout .board-wrap:fullscreen .fullscreen-exit-button,
  .phone-layout body.mobile-board-fullscreen .fullscreen-exit-button {
    position: static;
    grid-area: exit;
    align-self: center;
    justify-self: end;
  }

  .phone-layout .board-wrap:fullscreen .board,
  .phone-layout body.mobile-board-fullscreen .board-wrap .board {
    grid-area: board;
    width: min(calc(100dvw - 16px), calc(100dvh - 76px));
  }

  .phone-layout .online-match-active .board-wrap:fullscreen .fullscreen-opponent-panel,
  .phone-layout body.online-match-active.mobile-board-fullscreen .fullscreen-opponent-panel {
    grid-area: opponent;
  }
}
/* Normal-size mobile online match in landscape: match data, puzzle and opponent get separate columns. */
@media (orientation: landscape) and (max-width: 1000px) {
  .phone-layout body.mobile-online-mode .app-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .phone-layout body.mobile-online-mode.online-match-active .game-area {
    grid-template-columns: minmax(145px, 20dvw) minmax(0, 1fr) minmax(130px, 20dvw);
    align-items: start;
    gap: 8px;
  }

  .phone-layout body.mobile-online-mode.online-match-active .online-match-bar {
    grid-column: 1;
    grid-row: 1;
    grid-template-columns: 1fr;
    align-content: start;
  }

  .phone-layout body.mobile-online-mode.online-match-active .online-match-bar .match-summary {
    grid-column: 1;
  }

  .phone-layout body.mobile-online-mode.online-match-active .match-clock,
  .phone-layout body.mobile-online-mode.online-match-active #leaveMatchBtn {
    grid-column: 1;
    width: 100%;
  }

  .phone-layout body.mobile-online-mode.online-match-active .board-panel {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
  }

  .phone-layout body.mobile-online-mode.online-match-active .board {
    width: min(100%, calc(100dvh - 20px));
    max-width: none;
    margin: 0 auto;
  }

  .phone-layout body.mobile-online-mode.online-match-active .opponent-panel {
    grid-column: 3;
    grid-row: 1;
    min-width: 0;
    max-width: none;
    margin: 0;
    padding: 10px;
  }

  .phone-layout body.mobile-online-mode.online-match-active .opponents-container {
    max-height: calc(100dvh - 20px);
    overflow-y: auto;
  }

  .phone-layout body.mobile-online-mode.online-match-active .opponent-grid {
    width: min(100%, 120px);
  }
}
