﻿* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #f7fbff;
  --bg2: #eef6ff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #2f2f2f;
  --chip: #f8fbff;
  --chipBorder: #e6eef8;
  --winner: #fef3c7;
}

html,
body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

body,
button,
input,
select,
textarea {
  font-family: 'Arimo', Arial, sans-serif;
}

body {
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg2) 100%);
  min-height: 100vh;
  color: var(--text);
  padding: 8px;
}

.app {
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  justify-content: center;
}

.framedScreen {
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
}

.panel {
  width: 100%;
  max-width: 800px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  padding: 12px 10px 10px;
  border-radius: 24px;
  box-shadow:
    0 14px 30px rgba(16, 24, 40, 0.10),
    0 0 0 1px rgba(223,234,251,.95),
    inset 0 1px 0 rgba(255,255,255,.96);
  min-height: 660px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  border: 1px solid #dfeafb;
  position: relative;
  overflow: hidden;
}

.panel::before {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 18px;
  border: 1px solid #edf4fd;
  pointer-events: none;
}

.hidden { display: none !important; }
.center { text-align: center; }

.title {
  font-size: 3em;
  text-align: center;
  margin-top: 26px;
  margin-bottom: 10px;
  font-weight: 900;
  letter-spacing: -0.03em;
  line-height: 1;
}

.title .redWord {
  color: #ef4444;
  text-shadow: 0 8px 18px rgba(239, 68, 68, 0.14);
}

.title .blueWord {
  color: #3b82f6;
  text-shadow: 0 8px 18px rgba(59, 130, 246, 0.14);
}

.subtitle {
  text-align: center;
  color: var(--muted);
  margin-bottom: 18px;
  font-size: 1em;
}

.buttonRow {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: nowrap;
}

.buttonRow.onlineRow {
  margin-top: 7px;
}

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

.btn {
  width: auto;
  min-width: 132px;
  color: white;
  border: none;
  padding: 12px 20px;
  font-size: 1em;
  border-radius: 18px;
  cursor: pointer;
  margin: 0;
  transition: all .22s ease;
  font-weight: 800;
  background: linear-gradient(180deg, #57adff 0%, #2b88f7 62%, #1b6edc 100%);
  box-shadow: 0 6px 0 #1a63c1, 0 14px 26px rgba(43,136,247,.18), inset 0 1px 0 rgba(255,255,255,.45);
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 0 #1a63c1, 0 18px 30px rgba(43,136,247,.22), inset 0 1px 0 rgba(255,255,255,.45);
}

.btn:active {
  transform: translateY(3px);
  box-shadow: 0 3px 0 #1a63c1, 0 10px 18px rgba(43,136,247,.16), inset 0 1px 0 rgba(255,255,255,.45);
}

.btn.red {
  background: linear-gradient(180deg, #ff7474 0%, #ff4545 62%, #e92b2b 100%);
  box-shadow: 0 6px 0 #c71f1f, 0 14px 26px rgba(255,69,69,.16), inset 0 1px 0 rgba(255,255,255,.40);
}

.btn.red:hover {
  box-shadow: 0 8px 0 #c71f1f, 0 18px 30px rgba(255,69,69,.20), inset 0 1px 0 rgba(255,255,255,.40);
}

.btn.green {
  background: linear-gradient(180deg, #4ade80 0%, #22c55e 62%, #16a34a 100%);
  box-shadow: 0 6px 0 #15803d, 0 14px 26px rgba(34, 197, 94, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

.btn.green:hover {
  box-shadow: 0 8px 0 #15803d, 0 18px 30px rgba(34, 197, 94, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

.btn.green:active {
  box-shadow: 0 3px 0 #15803d, 0 10px 18px rgba(34, 197, 94, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

.btn.gray {
  background: linear-gradient(180deg, #e5e7eb 0%, #d1d5db 62%, #9ca3af 100%);
  color: #374151;
  box-shadow: 0 6px 0 #6b7280, 0 14px 26px rgba(107, 114, 128, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.5);
  cursor: default;
}

.btn.gray:hover,
.btn.gray:active {
  transform: none;
  box-shadow: 0 6px 0 #6b7280, 0 14px 26px rgba(107, 114, 128, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.small-btn {
  width: auto;
  min-width: 120px;
  background: linear-gradient(180deg, #57adff 0%, #2b88f7 62%, #1b6edc 100%);
  color: white;
  border: none;
  padding: 12px 16px;
  border-radius: 18px;
  cursor: pointer;
  font-size: .96em;
  font-weight: 800;
  transition: all .22s ease;
  box-shadow: 0 6px 0 #1a63c1, 0 14px 26px rgba(43,136,247,.18), inset 0 1px 0 rgba(255,255,255,.45);
}

.small-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 0 #1a63c1, 0 18px 30px rgba(43,136,247,.22), inset 0 1px 0 rgba(255,255,255,.45);
}

.small-btn:active {
  transform: translateY(3px);
  box-shadow: 0 3px 0 #1a63c1, 0 10px 18px rgba(43,136,247,.16), inset 0 1px 0 rgba(255,255,255,.45);
}

.small-btn.red {
  background: linear-gradient(180deg, #ff7474 0%, #ff4545 62%, #e92b2b 100%);
  box-shadow: 0 6px 0 #c71f1f, 0 14px 26px rgba(255,69,69,.16), inset 0 1px 0 rgba(255,255,255,.40);
}

.small-btn.red:hover {
  box-shadow: 0 8px 0 #c71f1f, 0 18px 30px rgba(255,69,69,.20), inset 0 1px 0 rgba(255,255,255,.40);
}

.option-section { margin: 12px 0; }

.option-section h2 {
  color: #22324a;
  font-size: 1.02em;
  margin-bottom: 8px;
  text-align: center;
  font-weight: 800;
}

.option-buttons {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: nowrap;
  margin: 0 auto;
  max-width: 100%;
}

.option-btn {
  background: white;
  border: 2px solid #e7eef8;
  color: #334155;
  padding: 8px 10px;
  border-radius: 14px;
  cursor: pointer;
  transition: all .2s ease;
  font-size: .85em;
  font-weight: 800;
  box-shadow: 0 6px 14px rgba(15,23,42,.04);
  min-width: 88px;
  line-height: 1.2;
}

.option-btn:hover {
  border-color: #93c5fd;
  background: #eff6ff;
  transform: translateY(-1px);
}

.option-btn.selected {
  background: linear-gradient(180deg, #57adff 0%, #2b88f7 62%, #1b6edc 100%);
  color: white;
  border-color: #2b88f7;
  box-shadow: 0 10px 18px rgba(59,130,246,.16);
}

.option-btn small {
  display: block;
  font-size: .72em;
  opacity: .9;
  margin-top: 3px;
}

.openSettings {
  max-width: 620px;
  margin: 36px auto 0;
  padding-top: 10px;
  border-top: 1px dashed #dbe7f5;
}

.startHint {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  color: #4b5563;
  font-weight: 800;
  margin-bottom: 18px;
  font-size: 1.02em;
}

.startHint .arrow {
  color: #ef4444;
  font-size: 1.15em;
  line-height: 1;
}

.hudTop,
.gameHud,
.gameHudFooter,
.scoreRowTop,
.turnArea,
.belowBoardInfo {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  width: 100%;
}

.gameHud {
  flex-direction: column;
  align-items: center;
  margin-top: 0;
  gap: 0;
  width: 100%;
}

.gameHudFooter {
  flex-direction: column;
  align-items: center;
  gap: 0;
  width: 100%;
  margin-top: 6px;
}

.hudTop {
  margin-top: 14px;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
}

.scoreRowTop {
  display: flex;
  justify-content: center;
  gap: 6px;
  flex-wrap: nowrap;
  width: auto;
  margin: 0 0 8px;
}

.turnArea {
  display: flex;
  justify-content: center;
  align-items: center;
  width: auto;
  flex: 0 0 auto;
  margin: 20px 0 24px;
}

.turnArea .badge.turn {
  width: auto;
  max-width: 280px;
  min-width: 0;
  justify-content: center;
  padding: 10px 22px;
}

.gameHudFooter .actions {
  margin-bottom: 10px;
}

.belowBoardInfo {
  gap: 10px;
  flex-wrap: nowrap;
  margin-bottom: 4px;
}

.actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: nowrap;
  width: 100%;
}

.badge {
  background: linear-gradient(180deg, #ffffff 0%, var(--chip) 100%);
  border-radius: 999px;
  padding: 10px 16px;
  font-size: .95em;
  font-weight: 700;
  box-shadow: 0 8px 18px rgba(15,23,42,.06);
  border: 1px solid var(--chipBorder);
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.badge strong { font-weight: 800; }
.badge.turn strong { color: #111827; }
.badge.size strong { color: #ef4444; }
.badge.diff strong { color: #0f766e; }

.settings-chip {
  cursor: pointer;
  font-family: inherit;
  color: #1e40af;
  font-weight: 800;
  transition: transform .18s ease, box-shadow .18s ease;
}

.settings-chip:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(37, 99, 235, 0.12);
}

.settings-chip.hidden { display: none; }

.scoreMini {
  min-width: 88px;
  background: linear-gradient(180deg, #ffffff 0%, var(--chip) 100%);
  border-radius: 16px;
  padding: 8px 12px;
  box-shadow: 0 8px 18px rgba(15,23,42,.06);
  border: 1px solid var(--chipBorder);
  text-align: center;
  display: inline-flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  gap: 8px;
  min-height: 42px;
}

.scoreMini .label {
  display: inline-block;
  font-size: 1em;
  color: #64748b;
  font-weight: 900;
  line-height: 1;
}

.scoreMini .value {
  font-size: 1.12em;
  font-weight: 900;
  line-height: 1;
}

.scoreMini.x .value { color: #2563eb; }
.scoreMini.o .value { color: #ef4444; }
.scoreMini.tie .value { color: #f59e0b; }

.gameFixedArea {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  min-height: 520px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 42px 2px 18px;
}

.boardStage {
  flex: 0 1 auto;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 340px;
  margin-top: 38px;
  margin-bottom: 0;
}

.boardWrap {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
}

.board-sound-toggle {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--chipBorder);
  border-radius: 999px;
  background: linear-gradient(180deg, #ffffff 0%, var(--chip) 100%);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.06);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  display: inline-grid;
  place-items: center;
  min-height: 44px;
}

@media (max-width: 700px) {
  .board-sound-toggle {
    width: 40px;
    height: 40px;
    min-height: 40px;
    font-size: 1.05rem;
  }
}

.board-sound-toggle.is-muted {
  opacity: 0.78;
  background: #f3f4f6;
}

.online-settings-title-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 14px;
}

.online-settings-title-row h3 {
  margin-bottom: 0;
}

.settings-sound-toggle {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 3px 0 rgba(47, 47, 47, 0.1);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.settings-sound-toggle.is-muted {
  opacity: 0.78;
  background: #f3f4f6;
}

.board {
  display: grid;
  gap: 0;
  position: relative;
}

.board.size-3 {
  grid-template-columns: repeat(3, 138px);
  grid-template-rows: repeat(3, 138px);
}

.board.size-5 {
  grid-template-columns: repeat(5, 96px);
  grid-template-rows: repeat(5, 96px);
}

.board.size-7 {
  grid-template-columns: repeat(7, 72px);
  grid-template-rows: repeat(7, 72px);
}

.cell {
  background: white;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: all .18s ease;
  position: relative;
  border: 2px solid var(--line);
}

.board.size-3 .cell:nth-child(-n+3) { border-top: none; }
.board.size-3 .cell:nth-child(3n+1) { border-right: none; }
.board.size-3 .cell:nth-child(3n) { border-left: none; }
.board.size-3 .cell:nth-last-child(-n+3) { border-bottom: none; }

.board.size-5 .cell:nth-child(-n+5) { border-top: none; }
.board.size-5 .cell:nth-child(5n+1) { border-right: none; }
.board.size-5 .cell:nth-child(5n) { border-left: none; }
.board.size-5 .cell:nth-last-child(-n+5) { border-bottom: none; }

.board.size-7 .cell:nth-child(-n+7) { border-top: none; }
.board.size-7 .cell:nth-child(7n+1) { border-right: none; }
.board.size-7 .cell:nth-child(7n) { border-left: none; }
.board.size-7 .cell:nth-last-child(-n+7) { border-bottom: none; }

.cell:hover:not(.taken) { background: #f9fafb; }
.cell.taken { cursor: default; }

.cell svg {
  width: 75%;
  height: 75%;
  filter: drop-shadow(2px 4px 6px rgba(0,0,0,.15));
  animation: placeSymbol .4s cubic-bezier(.68,-.55,.265,1.55);
}

@keyframes placeSymbol {
  0% { transform: scale(0) rotate(-180deg); opacity: 0; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}

.cell.winning {
  animation: winPulse .6s ease-in-out infinite;
  background: var(--winner);
}

@keyframes winPulse {
  0%,100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  padding: 20px 20px 24px;
}

.modal.show { display: flex; }

.modal-content {
  background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
  padding: 36px 28px;
  border-radius: 30px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,.22);
  border: 1px solid rgba(255,255,255,.95);
  animation: modalPop .4s cubic-bezier(.68,-.55,.265,1.55);
  max-width: 420px;
  width: 100%;
  margin-bottom: 0;
}

#winModal {
  align-items: flex-end;
  padding-bottom: 12px;
  z-index: 1000;
}

#actionRequestModal {
  z-index: 2000;
}

#winModal .modal-content {
  margin-bottom: 0;
}

#winMessage {
  white-space: pre-line;
}

#winMessage .win-score-line {
  display: inline-block;
  font-size: 0.45em;
  font-weight: 700;
  white-space: nowrap;
  line-height: 1.3;
  margin-top: 0.25em;
}

#winMessage .win-emoji {
  -webkit-text-fill-color: initial;
  background: none;
  background-clip: unset;
  -webkit-background-clip: unset;
}

@keyframes modalPop {
  0% { transform: scale(.5); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

#ad-loading {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 2500;
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(4px);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 24px;
  text-align: center;
}

#ad-loading.show {
  display: flex;
}

#ad-loading .ad-loading-title {
  color: #fff;
  font-size: clamp(1.35rem, 4.5vw, 1.85rem);
  font-weight: 900;
  line-height: 1.35;
  margin: 0;
  max-width: 18em;
}

#ad-loading .ad-loading-timer {
  color: #93c5fd;
  font-size: clamp(2.4rem, 10vw, 3.4rem);
  font-weight: 900;
  margin: 0;
  letter-spacing: .02em;
  font-variant-numeric: tabular-nums;
  min-width: 1.4em;
}

#ad-loading.waiting-others .ad-loading-timer {
  color: #bfdbfe;
  font-size: clamp(1.8rem, 7vw, 2.6rem);
}

#ad-loading p {
  color: #fff;
  font-size: 1.1em;
  font-weight: 800;
  margin: 0;
}

.ad-ring {
  width: 54px;
  height: 54px;
  border: 5px solid rgba(147, 197, 253, 0.32);
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: adSpin .8s linear infinite;
}

@keyframes adSpin {
  to { transform: rotate(360deg); }
}

.modal h2 {
  font-size: 2em;
  margin-bottom: 22px;
  font-weight: 900;
  background: linear-gradient(135deg, #ef4444, #3b82f6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

#onlineModalTitle {
  background: none;
  -webkit-background-clip: unset;
  -webkit-text-fill-color: initial;
  background-clip: unset;
  color: #1f2937;
}

#onlineModalTitle .modal-title-text {
  background: linear-gradient(135deg, #ef4444, #3b82f6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  white-space: nowrap;
}

#onlineRoomModal.host-lobby .modal-content,
#onlineRoomModal .modal-content {
  max-width: 420px;
}

#onlineRoomModal.host-lobby .onlineStatus {
  margin-bottom: 6px;
  line-height: 1.4;
}

#onlineRoomModal .modal h2 {
  margin-bottom: 6px;
  font-size: 1.55em;
}

#onlineRoomModal .onlineSymbolLine {
  margin: 0 0 6px;
}

.modal-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: nowrap;
  width: 100%;
}

.btn.online {
  background: linear-gradient(180deg, #34d399 0%, #10b981 62%, #059669 100%);
  box-shadow: 0 6px 0 #047857, 0 14px 26px rgba(16,185,129,.18), inset 0 1px 0 rgba(255,255,255,.45);
  min-width: 160px;
}

.btn.online:hover {
  box-shadow: 0 8px 0 #047857, 0 18px 30px rgba(16,185,129,.22), inset 0 1px 0 rgba(255,255,255,.45);
}

.firebaseHint {
  margin-top: 14px;
  font-size: .88em;
  color: var(--muted);
}

.firebaseHint a {
  color: #2563eb;
  font-weight: 800;
  text-decoration: none;
}

.firebaseHint a:hover {
  text-decoration: underline;
}

.roomShareBox {
  margin: 10px 0 6px;
  padding: 12px 14px;
  background: #f0fdf4;
  border: 2px solid #bbf7d0;
  border-radius: 16px;
}

.roomCodeLabel {
  font-size: 1.08em;
  color: #166534;
  font-weight: 900;
  margin-bottom: 10px;
  text-align: center;
}

.roomLinkRow {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.roomLinkInput {
  flex: 1 1 100%;
  min-width: 0;
  padding: 9px 10px;
  border: 2px solid #d1fae5;
  border-radius: 12px;
  font-size: .78em;
  direction: ltr;
  text-align: left;
  background: white;
  color: #334155;
}

.onlineWaiting {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
  color: #166534;
  font-weight: 800;
}

.onlineStatus {
  font-size: .95em;
  color: var(--muted);
  margin-bottom: 12px;
  line-height: 1.5;
}

.board.waiting {
  pointer-events: none;
  opacity: 0.5;
  filter: grayscale(0.15);
}

@media (max-width: 820px) {
  .gameHud,
  .gameHud,
  .hudTop,
  .scoreRowTop,
  .turnArea,
  .belowBoardInfo,
  .gameHudFooter {
    justify-content: center;
  }
}

@media (max-width: 700px) {
  .panel { padding: 12px 9px 9px; min-height: 640px; }
  .title { font-size: 2.5em; margin-top: 26px; }
  .gameFixedArea { min-height: 490px; max-width: 100%; padding-top: 28px; }
  .boardStage { min-height: 340px; margin-top: 6px; }
  .board.size-3 { grid-template-columns: repeat(3, 110px); grid-template-rows: repeat(3, 110px); }
  .board.size-5 { grid-template-columns: repeat(5, 74px); grid-template-rows: repeat(5, 74px); }
  .board.size-7 { grid-template-columns: repeat(7, 56px); grid-template-rows: repeat(7, 56px); }
  .scoreMini { min-width: 82px; padding: 8px 10px; }
  .hudTop {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
  }
  .scoreRowTop { flex-wrap: wrap; }
  .belowBoardInfo {
    flex-wrap: nowrap;
    justify-content: center;
  }
  .actions {
    flex-wrap: nowrap;
    justify-content: center;
  }
  .modal {
    align-items: center;
    padding: 16px 12px 18px;
  }
  #winModal {
    align-items: flex-end;
    padding-bottom: 10px;
  }
}

@media (max-width: 520px) {
  .title { font-size: 2.1em; margin-top: 20px; }
  .panel { padding: 11px 8px 8px; min-height: 610px; border-radius: 20px; }
  .panel::before { inset: 4px; border-radius: 14px; }
  .option-buttons { gap: 6px; }
  .option-btn { min-width: 78px; font-size: .8em; padding: 8px 8px; }
  .actions { flex-direction: row; flex-wrap: nowrap; }
  .buttonRow, .modal-buttons { flex-direction: row; }
  .btn, .small-btn { min-width: 0; }
  .buttonRow .btn { flex: 1 1 0; }
  .buttonRow.onlineRow .btn.online {
    width: 100%;
    min-width: 0;
    flex: 1 1 100%;
  }
  .actions .small-btn, .modal-buttons .btn, .modal-buttons .small-btn { flex: 1 1 0; }
  .gameFixedArea { min-height: 430px; max-width: 100%; padding: 30px 2px 14px; }
  .boardStage { min-height: 270px; margin-top: 34px; }
  .turnArea { margin: 16px 0 20px; }
  .turnArea .badge.turn { max-width: 240px; padding: 8px 18px; font-size: .9em; }
  .scoreRowTop { margin: 0 0 6px; gap: 5px; }
  .gameHudFooter { margin-top: 4px; }
  .belowBoardInfo { margin-bottom: 2px; }
  .gameHud {
    gap: 0;
    margin-top: 8px;
    flex-direction: column;
    flex-wrap: nowrap;
    justify-content: center;
  }
  .board.size-3 { grid-template-columns: repeat(3, 95px); grid-template-rows: repeat(3, 95px); }
  .board.size-5 { grid-template-columns: repeat(5, 62px); grid-template-rows: repeat(5, 62px); }
  .board.size-7 { grid-template-columns: repeat(7, 46px); grid-template-rows: repeat(7, 46px); }
  .scoreRowTop {
    gap: 6px;
    flex-wrap: wrap;
  }
  .scoreMini { min-width: 76px; padding: 7px 9px; }
  .badge { padding: 8px 12px; }
  .belowBoardInfo {
    flex-wrap: nowrap;
    justify-content: center;
    gap: 6px;
  }
  .belowBoardInfo .badge {
    font-size: .82em;
    padding: 8px 10px;
  }
  .modal {
    align-items: center;
    padding: 10px 8px 12px;
  }
  .modal-content {
    border-radius: 24px 24px 18px 18px;
    max-width: 100%;
  }
  #onlineRoomModal.host-lobby .modal-content,
  #onlineRoomModal .modal-content {
    padding: 14px 12px 12px;
    border-radius: 18px;
    max-width: calc(100vw - 16px);
  }
  #onlineRoomModal.host-lobby #onlineModalTitle,
  #onlineRoomModal.host-lobby .modal h2 {
    margin-top: 14px;
    margin-bottom: 10px;
    font-size: 1.28em;
  }
  #onlineRoomModal .modal h2 {
    font-size: 1.28em;
    margin-bottom: 4px;
  }
  #onlineRoomModal .onlineStatus {
    font-size: .85em;
    margin-bottom: 4px;
  }
  #onlineRoomModal .onlineSymbolLine {
    margin: 0 0 4px;
    font-size: .88em;
  }
  #onlineRoomModal .roomShareBox {
    margin: 6px 0 4px;
    padding: 10px;
  }
  #onlineRoomModal .roomCodeLabel {
    font-size: 1em;
    margin-bottom: 8px;
  }
  #onlineRoomModal .roomLinkInput {
    font-size: .72em;
    padding: 8px;
  }
  #onlineRoomModal .onlineWaiting {
    margin: 8px 0 4px;
    gap: 6px;
  }
  #onlineRoomModal.host-lobby .onlineWaiting {
    margin: 14px 0 16px;
    gap: 10px;
  }
  #onlineRoomModal.host-lobby .wait-anim {
    margin-top: 12px;
  }
  #onlineRoomModal.host-lobby #onlineWaitingText {
    margin: 0 0 8px;
  }
  #onlineRoomModal.host-lobby .modal-buttons {
    justify-content: center;
  }
  #onlineRoomModal.host-lobby #closeOnlineModalBtn {
    flex: 0 0 auto;
    width: auto;
    min-width: 96px;
    max-width: 140px;
    padding-left: 18px;
    padding-right: 18px;
  }
  #onlineRoomModal .onlineLobbySize {
    margin-top: 8px;
    padding-top: 8px;
  }
  #onlineRoomModal .option-btn {
    min-width: 70px;
    padding: 7px 6px;
    font-size: .75em;
  }
  #winModal {
    align-items: flex-end;
    padding-bottom: 8px;
  }
}
/* ===== Desktop / iframe hardening ===== */
@media (min-width: 701px) {
  html,
  body {
    width: 100%;
    height: 100%;
    min-height: 100%;
    overflow: hidden !important;
  }

  body {
    display: block !important;
    padding: 0 !important;
    margin: 0 !important;
    background: linear-gradient(180deg, var(--bg) 0%, var(--bg2) 100%);
  }

  .app {
    position: fixed !important;
    inset: 0 !important;
    width: 100% !important;
    max-width: none !important;
    height: 100% !important;
    margin: 0 !important;
    display: block !important;
  }

  .framedScreen {
    width: 100% !important;
    max-width: none !important;
    height: 100% !important;
    margin: 0 !important;
  }

  .panel {
    width: 100% !important;
    max-width: none !important;
    min-height: 100% !important;
    height: 100% !important;
    border-radius: 0 !important;
    padding: 10px 12px 12px !important;
    margin: 0 !important;
  }

  .panel::before {
    inset: 6px !important;
    border-radius: 18px !important;
  }

  #openingScreen,
  #gameScreen {
    position: absolute !important;
    inset: 0 !important;
  }

  .gameFixedArea {
    width: 100% !important;
    max-width: none !important;
    height: 100% !important;
    min-height: 0 !important;
    padding: 0 8px 10px !important;
    justify-content: flex-start !important;
  }

  .boardStage {
    width: 100% !important;
    flex: 1 1 auto !important;
    min-height: 0 !important;
    margin-top: 18px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  .boardWrap {
    width: 100% !important;
    height: 100% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  .gameHudFooter {
    width: 100% !important;
    margin-top: 8px !important;
    padding-bottom: 4px !important;
  }

  .openSettings {
    max-width: 760px !important;
    margin: 28px auto 0 !important;
  }

  /* board sizes tuned for 800px iframe */
  .board.size-3 {
    grid-template-columns: repeat(3, 132px) !important;
    grid-template-rows: repeat(3, 132px) !important;
  }

  .board.size-5 {
    grid-template-columns: repeat(5, 88px) !important;
    grid-template-rows: repeat(5, 88px) !important;
  }

  .board.size-7 {
    grid-template-columns: repeat(7, 64px) !important;
    grid-template-rows: repeat(7, 64px) !important;
  }
}

/* --- Online mode enhancements --- */
.badge.turn.turn-my strong { color: #16a34a; }
.badge.turn.turn-urgent strong { color: #dc2626; }
.badge.turn.turn-urgent {
  border-color: #f87171;
  animation: turnUrgentPulse 0.8s ease-in-out infinite;
}
.badge.turn .turn-clock {
  display: inline-block;
  min-width: 1.4em;
  font-variant-numeric: tabular-nums;
  font-size: 1.15em;
}
@keyframes turnUrgentPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.35); }
  50% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}
.badge.turn.turn-opponent strong { color: #ff4d4d; }
.badge.turn.turn-ended strong { color: #6b7280; }

.onlineSymbolLine {
  font-size: 1em;
  font-weight: 800;
  color: #1d4ed8;
  margin: -4px 0 12px;
}

.onlineLobbySize {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #e6eef8;
}

.onlineLobbySize h2 {
  font-size: 1.05em;
  margin-bottom: 10px;
  text-align: center;
  color: #1f2937;
}

.onlineLobbySize .option-buttons {
  justify-content: center;
}

.onlineLobbySize.hidden { display: none; }

#gameScreen.online-active .actions { display: none !important; }

.online-settings-panel {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.online-settings-panel.hidden { display: none; }

.online-settings-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
}

.online-settings-content {
  position: relative;
  z-index: 1;
  width: min(420px, 94vw);
  background: #fff;
  border-radius: 24px 24px 0 0;
  padding: 20px 18px 24px;
  box-shadow: 0 -10px 40px rgba(15, 23, 42, 0.18);
}

.online-settings-content h3 {
  text-align: center;
  margin-bottom: 0;
  font-size: 1.2em;
}

.settings-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 14px 0;
}

.wait-anim {
  width: 190px;
  margin: auto;
}

.wait-anim .line {
  position: relative;
  height: 28px;
}

.wait-anim .line i {
  position: absolute;
  top: 50%;
  z-index: 3;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  transform: translateY(-50%);
}

.wait-anim .p2 {
  left: 0;
  background: #b7c2d8;
}

.wait-anim .me {
  right: 0;
  background: #28b86f;
  box-shadow: 0 0 0 4px rgba(40, 184, 111, 0.2);
}

.wait-anim .rail {
  position: absolute;
  left: 9px;
  right: 9px;
  top: 50%;
  height: 10px;
  overflow: hidden;
  border-radius: 10px;
  transform: translateY(-50%);
  background:
    repeating-linear-gradient(90deg, rgba(255,255,255,.32) 0 18px, transparent 18px 36px),
    #d8e1ef;
}

.wait-anim .signal {
  position: absolute;
  top: 0;
  left: -50px;
  width: 50px;
  height: 100%;
  border-radius: 10px;
  background: #4f87ff;
  animation: wait-connect 1.6s linear infinite;
}

.wait-anim small {
  display: flex;
  justify-content: space-between;
  margin-top: 3px;
  color: #8790a2;
  font-size: 14px;
  direction: ltr;
}

.wait-anim em {
  min-width: 55px;
  font-style: normal;
}

.wait-anim em:first-child {
  text-align: left;
  transform: translateX(-18px);
}

.wait-anim em:last-child {
  text-align: right;
  transform: translateX(18px);
}

@keyframes wait-connect {
  from { left: -50px; }
  to { left: 100%; }
}
