:root {
  color-scheme: dark;
  font-family: Inter, ui-rounded, "SF Pro Rounded", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --bg: #070916;
  --surface: #151a32;
  --surface-strong: #222858;
  --surface-soft: #0d1024;
  --game-chrome: #0d1024;
  --game-control: #151a32;
  --game-border: rgba(103, 232, 249, 0.78);
  --rose: #7c3aed;
  --pink: #f472b6;
  --lavender: #6d28d9;
  --blue: #38bdf8;
  --red: #fb7185;
  --text: #fffaff;
  --muted: #dbeafe;
  --line: rgba(103, 232, 249, 0.32);
  background: var(--bg);
  color: var(--text);
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 8% 4%, rgba(139, 92, 246, 0.20), transparent 30rem),
    radial-gradient(circle at 92% 14%, rgba(244, 114, 182, 0.16), transparent 34rem),
    linear-gradient(135deg, #070916 0%, #111638 42%, #312e81 50%, #12152e 60%, #070916 100%);
  background-attachment: fixed;
}

button { font: inherit; }

button:focus-visible,
canvas:focus-visible {
  outline: 3px solid var(--pink);
  outline-offset: 3px;
}

.app-shell {
  position: relative;
  z-index: 0;
  width: min(560px, 100%);
  margin: 0 auto;
  padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
}

.app-shell::before {
  content: "4NCut";
  position: fixed;
  z-index: 0;
  top: 34%;
  left: 50%;
  color: rgba(255, 255, 255, 0.045);
  font-size: clamp(5rem, 22vw, 9rem);
  font-weight: 950;
  letter-spacing: -0.08em;
  pointer-events: none;
  transform: translate(-50%, -50%) rotate(-18deg);
}

.app-shell > * { position: relative; z-index: 1; }

.topbar,
.mode-strip,
.score-row,
.actions,
.progress-card {
  display: flex;
}

.topbar {
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 8px;
  z-index: 50;
}

.eyebrow {
  margin: 0;
  color: var(--pink);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.14em;
}

h1 {
  margin: 2px 0 0;
  font-size: clamp(2rem, 6vw, 3.25rem);
  line-height: 1;
  letter-spacing: -0.05em;
}

.top-actions { display: flex; gap: 8px; }

.reaction-control { position: relative; }
.reaction-button { min-width: 48px; padding: 0; font-size: 1.25rem; }
.dot-style-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 58px;
  padding-inline: 8px;
  color: #fff;
  font-size: 1rem;
  line-height: 1;
}
.dot-style-button span:first-child { color: var(--blue); }
.dot-style-button span:last-child { color: var(--red); }
.dot-style-button i { color: rgba(255,255,255,.48); font-size: .7rem; font-style: normal; }
.reaction-popup {
  position: absolute;
  z-index: 100;
  top: calc(100% + 10px);
  right: 0;
  width: min(250px, calc(100vw - 28px));
  max-height: calc(100dvh - 96px);
  overflow-y: auto;
  padding: 8px;
  border: 1px solid rgba(103, 232, 249, 0.58);
  border-radius: 18px;
  background: rgba(7, 21, 15, 0.98);
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.48);
  backdrop-filter: blur(14px);
}
.reaction-popup[hidden] { display: none; }
.reaction-popup button {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 48px;
  padding: 8px 12px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-weight: 900;
  text-align: left;
}
.reaction-popup button:hover,
.reaction-popup button:focus-visible { background: rgba(139, 92, 246, 0.22); }
.reaction-popup span { width: 38px; font-size: 1.35rem; }
.reaction-popup small {
  margin-left: auto;
  color: var(--pink);
  font-size: 0.62rem;
  font-weight: 950;
  letter-spacing: 0.06em;
}

.brand-row { display: flex; align-items: center; gap: 9px; }
.profile-button {
  width: 38px;
  height: 38px;
  padding: 0;
  border: 2px solid var(--game-border);
  border-radius: 50%;
  overflow: hidden;
  background: var(--game-control);
  cursor: pointer;
}
.profile-button img { width: 100%; height: 100%; object-fit: cover; display: block; }
.reaction-popup button[data-premium="true"] { color: #f5d0fe; }

.match-event-bar {
  width: min(100%, 520px);
  min-height: 42px;
  margin: 0 auto 7px;
  padding: 8px 14px;
  border: 2px solid var(--game-border);
  border-radius: 10px;
  background: var(--game-chrome);
  color: var(--text);
  font-size: clamp(1.05rem, 3vw, 1.35rem);
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.28);
  animation: reactionIn 220ms ease-out;
}
@keyframes reactionIn { from { opacity: 0; transform: translateY(-8px) scale(0.96); } }

.match-event-bar[data-kind^="well_lined"] {
  animation: wellLinedGlow 720ms ease-in-out infinite alternate;
  background: linear-gradient(110deg, #111638, #312e81, #111638);
}

@keyframes wellLinedGlow {
  from { transform: scale(0.985); box-shadow: 0 0 10px currentColor, 0 12px 34px rgba(0, 0, 0, 0.34); }
  to { transform: scale(1.035); box-shadow: 0 0 28px currentColor, 0 16px 42px rgba(0, 0, 0, 0.44); }
}

.icon-button,
.mode-button,
.primary,
.secondary {
  min-height: 46px;
  border-radius: 15px;
  border: 1px solid var(--line);
  color: var(--text);
  cursor: pointer;
  font-weight: 850;
  transition: transform 120ms ease, border-color 150ms ease, background 150ms ease, box-shadow 150ms ease;
}

button:hover { border-color: rgba(103, 232, 249, 0.72); }
button:active { transform: translateY(1px) scale(0.99); }

.icon-button,
.secondary {
  padding: 0 15px;
  background: var(--game-control);
}

.icon-button[aria-pressed="false"] { color: rgba(255, 250, 255, 0.58); }

.mode-strip {
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
  padding: 9px;
  border: 2px solid rgba(103, 232, 249, 0.48);
  border-radius: 18px;
  background: var(--game-control);
}

.mode-button {
  flex: 1 1 86px;
  padding: 0 18px;
  background: transparent;
}

.mode-button.active {
  border-color: rgba(167, 215, 189, 0.78);
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.96), rgba(219, 39, 119, 0.90));
  box-shadow: 0 10px 26px rgba(139, 92, 246, 0.28);
}

#modeNote {
  display: none;
}

.premium-offer-button {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding-block: 0;
  line-height: 1;
}

.premium-offer-button small {
  color: #fef08a;
  font-size: 0.58rem;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  gap: 8px;
}

.board-column { min-width: 0; }

.board-frame {
  position: relative;
  width: min(100%, 520px);
  aspect-ratio: 0.86;
  margin: 0 auto;
  padding: clamp(7px, 1vw, 12px);
  border: 2px solid var(--game-border);
  border-radius: clamp(24px, 4vw, 38px);
  background: linear-gradient(145deg, #312e81 0%, #151a32 38%, #0d1024 66%, #222858 100%);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.58), inset 0 1px rgba(255, 255, 255, 0.12);
}

#board {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: clamp(18px, 3vw, 29px);
  cursor: crosshair;
  touch-action: none;
}

.board-help {
  margin: 11px auto 0;
  max-width: 680px;
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.45;
  text-align: center;
}

.player-block-controls {
  display: flex;
  justify-content: center;
  width: min(100%, 520px);
  margin: 7px auto 0;
}

.block-token-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 6px 10px;
  border: 2px solid rgba(56, 189, 248, .45);
  border-radius: 13px;
  background: rgba(7, 21, 15, .92);
  color: white;
  font: inherit;
  font-size: .76rem;
  font-weight: 900;
  letter-spacing: .04em;
}
.block-token-button.opponent { border-color: rgba(251, 113, 133, .45); }
.block-token-button.active { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(56, 189, 248, .13); }
.block-token-button.opponent.active { border-color: var(--red); box-shadow: 0 0 0 2px rgba(251, 113, 133, .13); }
.block-token-button.selected { border-color: #fbbf24; background: rgba(120, 53, 15, .72); }
.block-token-button:disabled { opacity: .72; }
.black-dot {
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
  border: 2px solid #94a3b8;
  border-radius: 50%;
  background: #020617;
  box-shadow: inset 0 0 0 2px #000, 0 1px 5px rgba(0,0,0,.7);
}
.board-hint-button { min-height: 40px; min-width: 118px; padding: 0 18px; }

.game-panel {
  display: grid;
  gap: 8px;
  position: static;
  width: min(100%, 520px);
  margin: 0 auto;
}

.score-row { gap: 10px; }

.score-card,
.status-card,
.outlook-card,
.progress-card {
  border: 2px solid rgba(103, 232, 249, 0.44);
  background: var(--game-control);
}

.score-card {
  flex: 1;
  padding: 15px 12px;
  border-radius: 18px;
  text-align: center;
}

.score-card span {
  display: block;
  min-height: 2em;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.score-card strong { font-size: 2rem; }

.player-timer {
  display: inline-block;
  min-width: 48px;
  margin-top: 4px;
  padding: 3px 8px;
  border: 1px solid rgba(148, 163, 184, .34);
  border-radius: 999px;
  color: var(--muted);
  font-size: .72rem;
  font-variant-numeric: tabular-nums;
  font-weight: 900;
}
.player-timer.active { border-color: currentColor; color: #e0f2fe; background: rgba(14, 116, 144, .28); }
.score-card.opponent .player-timer.active { color: #ffe4e6; background: rgba(159, 18, 57, .28); }
.player-timer.urgent { color: #fecaca; background: rgba(127, 29, 29, .55); }

.score-card.active {
  border-color: var(--blue);
  background: rgba(14, 116, 144, 0.28);
}

.score-card.opponent.active {
  border-color: var(--red);
  background: rgba(159, 18, 57, 0.25);
}

.outlook-card {
  padding: 13px 15px;
  border-radius: 18px;
}

.outlook-timer-row {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(72px, 1fr);
  gap: 8px;
  align-items: stretch;
}

.outlook-labels {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: clamp(0.86rem, 2.2vw, 1rem);
}

.outlook-labels strong:first-child { color: var(--blue); }
.outlook-labels strong:last-child { color: var(--red); text-align: right; }
.outlook-labels span { color: var(--muted); font-size: 0.64rem; letter-spacing: 0.08em; }
.outlook-track { height: 11px; overflow: hidden; border-radius: 999px; background: var(--red); }
.outlook-track span { display: block; height: 100%; width: 50%; background: var(--blue); transition: width 260ms ease; }

.status-card {
  min-height: 166px;
  padding: 22px;
  border-radius: 22px;
}

.turn-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.turn-heading .eyebrow { margin: 0; font-size: 0.82rem; }

.turn-timer {
  display: grid;
  min-width: 72px;
  padding: 7px 9px;
  place-items: center;
  border: 1px solid rgba(103, 232, 249, 0.52);
  border-radius: 18px;
  background: rgba(139, 92, 246, 0.18);
  color: #fce7f3;
  font-size: clamp(1.25rem, 4vw, 1.65rem);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.turn-timer.urgent {
  border-color: rgba(248, 113, 113, 0.82);
  background: rgba(127, 29, 29, 0.42);
  color: #fecaca;
}

.status-card h2 {
  margin: 8px 0 7px;
  font-size: clamp(1.25rem, 2vw, 1.62rem);
  line-height: 1.25;
}

.status-card > p:last-child {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.actions { gap: 10px; }
.actions button { flex: 1; }
.tactical-actions button:first-child[aria-pressed="true"] {
  border-color: #fbbf24;
  background: rgba(180, 83, 9, 0.34);
}

button:disabled { cursor: not-allowed; opacity: 0.46; }

.match-settings {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(16, 37, 28, 0.88);
  overflow: hidden;
}

.mode-button.utility-button {
  border-color: rgba(103, 232, 249, 0.48);
  background: rgba(18, 52, 38, 0.88);
}

.match-settings > summary {
  min-height: 46px;
  padding: 13px 16px;
  cursor: pointer;
  color: var(--muted);
  font-weight: 800;
}

.match-active .match-settings,
.match-active .auxiliary-actions { display: none; }

.orientation-guard { display: none; }

.board-frame.route-complete { animation: routePulse 380ms ease; }

@keyframes routePulse {
  50% { box-shadow: 0 0 0 4px rgba(103, 232, 249, 0.34), 0 24px 70px rgba(0, 0, 0, 0.35); }
}

.primary {
  padding: 0 20px;
  border-color: rgba(103, 232, 249, 0.82);
  background: linear-gradient(135deg, var(--rose), var(--lavender));
  box-shadow: 0 13px 28px rgba(126, 34, 206, 0.23);
}

.progress-card {
  flex-direction: column;
  gap: 0;
  overflow: hidden;
  border-radius: 20px;
}

.progress-card div {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 16px;
  border-bottom: 1px solid rgba(103, 232, 249, 0.16);
}

.progress-card div:last-child { border-bottom: 0; }
.progress-card span { color: var(--muted); }
.progress-card strong { text-align: right; }

.skin-picker {
  display: grid;
  gap: 9px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(16, 37, 28, 0.94);
}

.skin-picker-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.skin-picker h3 { margin: 2px 0 4px; font-size: 1rem; }
.skin-picker label { color: var(--muted); font-size: 0.82rem; font-weight: 800; }
.skin-picker select {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid rgba(103, 232, 249, 0.30);
  border-radius: 12px;
  color: #fff;
  background: #0d1024;
  font: inherit;
}

.included-badge {
  flex: 0 0 auto;
  padding: 5px 9px;
  border-radius: 999px;
  color: #d1fae5;
  background: rgba(5, 150, 105, 0.22);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.premium-skins summary {
  margin-top: 4px;
  color: var(--rose);
  cursor: pointer;
  font-weight: 850;
}

.premium-skin-grid {
  display: flex;
  gap: 12px;
  margin-top: 14px;
  padding: 12px 5px 18px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  overscroll-behavior-inline: contain;
}

.skin-carousel-card {
  position: relative;
  flex: 0 0 min(248px, 78vw);
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 18px;
  background: rgba(6, 18, 13, 0.82);
  scroll-snap-align: center;
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.skin-carousel-card.selected {
  z-index: 2;
  border-color: rgba(103, 232, 249, 0.90);
  box-shadow: 0 16px 38px rgba(190, 24, 93, 0.3);
  transform: scale(1.035);
}
.skin-carousel-card > img { display: block; width: 100%; height: 138px; object-fit: contain; background: #070916; }
.skin-card-copy { display: grid; gap: 3px; padding: 10px 10px 8px; }
.skin-card-copy strong { overflow: hidden; color: #fff; font-size: .86rem; text-overflow: ellipsis; white-space: nowrap; }
.skin-card-copy span { color: var(--muted); font-size: .72rem; font-weight: 800; }
.skin-carousel-card .skin-lock {
  position: absolute;
  top: 7px;
  right: 7px;
  padding: 4px 7px;
  border-radius: 999px;
  color: #fff;
  background: rgba(6, 18, 13, .88);
  font-size: .62rem;
  font-weight: 900;
  text-transform: uppercase;
  backdrop-filter: blur(4px);
}
.card-board-sample,
.skin-board-sample {
  position: relative;
  height: 94px;
  overflow: hidden;
  border-block: 1px solid rgba(103, 232, 249, 0.36);
  background-image: linear-gradient(to bottom, #070916 0 50%, transparent 50%), var(--skin-image);
  background-repeat: no-repeat;
  background-position: center, center;
  background-size: 100% 100%, cover;
}
.card-board-sample::before,
.skin-board-sample::before {
  content: "";
  position: absolute;
  inset: 7px;
  background-image: radial-gradient(circle, rgba(255,255,255,.82) 0 2px, transparent 2.5px);
  background-size: 28px 20px;
}
.skin-card-actions { display: flex; gap: 7px; padding: 0 9px 10px; }
.skin-card-actions button {
  flex: 1;
  min-height: 36px;
  border: 1px solid rgba(103, 232, 249, 0.52);
  border-radius: 10px;
  background: rgba(124, 58, 237, 0.42);
  color: #fff;
  cursor: pointer;
  font-size: .72rem;
  font-weight: 900;
}

.shop-dialog {
  width: min(720px, 100%);
  max-height: min(92dvh, 900px);
  overflow-y: auto;
  padding: clamp(18px, 4vw, 30px);
  border: 1px solid rgba(103, 232, 249, 0.58);
  border-radius: 26px;
  background: var(--surface-strong);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.55);
}
.dot-style-dialog { width: min(660px, 100%); }
.dot-style-player-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 14px 0;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(7, 9, 22, .72);
}
.dot-style-player-tabs button {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 900;
}
.dot-style-player-tabs button.selected:first-child {
  border-color: rgba(56,189,248,.82);
  background: rgba(56,189,248,.16);
  color: #e0f2fe;
}
.dot-style-player-tabs button.selected:last-child {
  border-color: rgba(251,113,133,.82);
  background: rgba(251,113,133,.16);
  color: #ffe4e6;
}
.dot-style-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
}
.dot-style-choice {
  position: relative;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 4px;
  min-height: 108px;
  padding: 9px 5px;
  border: 1px solid rgba(103,232,249,.25);
  border-radius: 15px;
  background: rgba(13,16,36,.84);
  color: #fff;
  cursor: pointer;
  text-align: center;
}
.dot-style-choice:hover,
.dot-style-choice:focus-visible { background: rgba(49,46,129,.48); }
.dot-style-choice.selected {
  border: 2px solid var(--pink);
  background: linear-gradient(145deg, rgba(124,58,237,.42), rgba(219,39,119,.28));
  box-shadow: 0 0 20px rgba(244,114,182,.24);
}
.dot-style-choice.premium { color: rgba(255,255,255,.88); }
.dot-style-glyph {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 2px solid rgba(103,232,249,.66);
  border-radius: 50%;
  background: rgba(4,9,22,.9);
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", system-ui, sans-serif;
  font-size: 1.45rem;
  line-height: 1;
}
.dot-style-choice strong { font-size: .78rem; line-height: 1.15; }
.dot-style-choice small { color: #a7f3d0; font-size: .55rem; font-weight: 950; letter-spacing: .06em; }
.dot-style-choice.premium small { color: #f5d0fe; }
.dot-style-status {
  min-height: 44px;
  margin: 12px 0 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(7,9,22,.72);
  color: var(--muted);
  font-weight: 800;
  line-height: 1.35;
  text-align: center;
}
.dot-style-status[data-kind="premium"] { border-color: rgba(244,114,182,.72); color: #fbcfe8; }
.dot-style-status[data-kind="selected"] { border-color: rgba(52,211,153,.72); color: #d1fae5; }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.dialog-heading h2 { margin: 6px 0 0; font-size: clamp(1.35rem, 5vw, 2rem); }
.dialog-copy,
.purchase-note { color: var(--muted); line-height: 1.5; }
.skin-feature {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 10px;
  margin-top: 14px;
}
.skin-feature > img {
  width: 100%;
  height: 190px;
  object-fit: contain;
  border-radius: 16px;
  background: #090611;
}
.skin-feature .skin-board-sample { height: 190px; border: 1px solid rgba(249,168,212,.3); border-radius: 16px; }
.skin-board-sample > span {
  position: absolute;
  z-index: 2;
  bottom: 8px;
  left: 8px;
  padding: 4px 7px;
  border-radius: 999px;
  background: rgba(7,3,12,.76);
  font-size: .62rem;
  font-weight: 900;
}
.skin-feature > div:last-child { grid-column: 1 / -1; display: flex; justify-content: space-between; gap: 14px; }
.skin-feature > div:last-child span { color: var(--pink); font-size: .8rem; font-weight: 900; }
.premium-benefits { display: grid; gap: 10px; padding: 0; list-style: none; }
.premium-benefits li { display: grid; gap: 3px; padding: 13px 15px; border: 1px solid var(--line); border-radius: 14px; background: rgba(13,16,36,.72); }
.premium-benefits span { color: var(--muted); font-size: .88rem; }
.premium-buy { width: 100%; min-height: 68px; font-weight: 900; }
.premium-buy small { font-weight: 800; }
.premium-promotion {
  margin: 0;
  padding: 12px 14px;
  border: 1px solid rgba(250, 204, 21, 0.68);
  border-radius: 14px;
  color: #fef9c3;
  background: rgba(113, 63, 18, 0.42);
  text-align: center;
}
.premium-code-label {
  display: block;
  margin: 4px 0 8px;
  color: var(--text);
  font-size: .9rem;
  font-weight: 850;
}
.premium-code-field {
  width: 100%;
  min-height: 52px;
  margin: 0 0 12px;
  border: 2px solid rgba(123,182,154,.78);
  border-radius: 13px;
  background: #0d1024;
  color: #fff;
  padding: 11px 13px;
  font: 850 1rem/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.premium-code-field::placeholder { color: rgba(233,245,238,.58); }
.premium-code-field:focus-visible { outline: 3px solid #38bdf8; outline-offset: 2px; }

.online-name-dialog { width: min(500px, 100%); }
.online-name-dialog h2 { margin: 6px 0 8px; font-size: clamp(1.5rem, 6vw, 2.15rem); }
.online-name-dialog label { display: block; margin: 18px 0 8px; color: var(--text); font-size: .82rem; font-weight: 900; letter-spacing: .08em; }
.online-name-field {
  width: 100%;
  min-height: 56px;
  border: 2px solid rgba(103, 232, 249, .58);
  border-radius: 14px;
  background: #0d1024;
  color: #fff;
  padding: 12px 14px;
  font: 850 1.05rem/1.2 Inter, ui-sans-serif, system-ui, sans-serif;
}
.online-name-field::placeholder { color: rgba(233,245,238,.56); }
.online-name-field:focus-visible { outline: 3px solid #f9a8d4; outline-offset: 2px; }
.online-name-actions { display: grid; grid-template-columns: 1fr 1.35fr; gap: 10px; margin-top: 18px; }
.online-name-actions button { min-height: 54px; }

.dialog-backdrop {
  position: fixed;
  z-index: 10;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(7, 3, 12, 0.78);
  backdrop-filter: blur(8px);
}

.dialog-backdrop[hidden] { display: none; }

.welcome-backdrop { z-index: 30; }
.welcome-dialog {
  display: grid;
  gap: 12px;
  width: min(620px, 100%);
  max-height: 94dvh;
  overflow-y: auto;
  padding: clamp(18px, 4vw, 30px);
  border: 2px solid rgba(103, 232, 249, 0.72);
  border-radius: 26px;
  background: linear-gradient(145deg, #0d1024, #222858);
  box-shadow: 0 32px 100px rgba(0, 0, 0, 0.72);
  text-align: center;
}
.welcome-dialog h2 { margin: 0; font-size: clamp(1.8rem, 7vw, 2.7rem); }
.welcome-dialog p { margin: 0; color: var(--muted); line-height: 1.45; }
.welcome-dialog small { color: var(--muted); }
.welcome-dialog .primary { width: 100%; min-height: 54px; }
.welcome-game-moment {
  width: 100%;
  max-height: 310px;
  object-fit: cover;
  border: 1px solid var(--game-border);
  border-radius: 20px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.42);
}
.welcome-account-note { font-size: .8rem; }
.legal-disclosure {
  padding: 12px 14px;
  border: 1px solid rgba(103, 232, 249, .45);
  border-radius: 15px;
  background: rgba(3, 18, 30, .72);
  text-align: left;
}
.legal-consent {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 10px;
  align-items: start;
  padding: 13px 14px;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 15px;
  background: rgba(8, 10, 27, .76);
  color: #f7fbff;
  text-align: left;
  line-height: 1.45;
}
.legal-consent input { width: 22px; height: 22px; margin: 0; accent-color: #38bdf8; }
.legal-consent a, .purchase-note a, .legal-footer a { color: #7dd3fc; font-weight: 800; }
.welcome-dialog .primary:disabled { opacity: .48; cursor: not-allowed; filter: grayscale(.35); }
.legal-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px 18px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 18px 20px calc(20px + env(safe-area-inset-bottom));
  color: var(--muted);
  font-size: .82rem;
}

.profile-summary { display: flex; align-items: center; gap: 14px; margin: 18px 0; }
.profile-summary img {
  width: 84px;
  height: 84px;
  object-fit: cover;
  border: 3px solid var(--game-border);
  border-radius: 50%;
}
.profile-summary > div { display: grid; gap: 5px; }
.profile-summary span { color: var(--muted); font-size: .88rem; }
.avatar-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.avatar-choice {
  display: grid;
  justify-items: center;
  gap: 7px;
  min-height: 138px;
  padding: 12px 8px;
  border: 2px solid var(--line);
  border-radius: 17px;
  background: rgba(7, 21, 15, .64);
  color: white;
  cursor: pointer;
  font-weight: 900;
}
.avatar-choice img { width: 82px; height: 82px; object-fit: cover; border-radius: 50%; }
.avatar-choice.selected { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(56, 189, 248, .2); }

.ranking-dialog { width: min(760px, 100%); }
.ranking-columns,
.ranking-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(64px, auto) minmax(56px, auto);
  align-items: center;
  gap: 10px;
}
.ranking-columns {
  position: sticky;
  top: -30px;
  z-index: 2;
  padding: 12px 14px 9px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-strong);
  color: var(--muted);
  font-size: .68rem;
  font-weight: 900;
  letter-spacing: .08em;
}
.ranking-columns span:not(:first-child) { text-align: right; }
.ranking-list { display: grid; gap: 7px; margin: 0; padding: 10px 0 0; list-style: none; }
.ranking-row {
  min-height: 62px;
  padding: 8px 14px;
  border: 1px solid rgba(103, 232, 249, .22);
  border-radius: 15px;
  background: rgba(7, 9, 22, .58);
}
.ranking-row.current-player { border-color: var(--pink); background: rgba(124, 58, 237, .26); box-shadow: 0 0 0 2px rgba(244, 114, 182, .10); }
.ranking-player { display: grid; grid-template-columns: 30px 42px minmax(0, 1fr); align-items: center; gap: 9px; min-width: 0; }
.ranking-position { color: var(--muted); font-size: .82rem; font-weight: 950; text-align: center; }
.ranking-row:nth-child(-n+3) .ranking-position { color: #fde68a; font-size: 1rem; }
.ranking-avatar { width: 42px; height: 42px; border: 2px solid var(--game-border); border-radius: 50%; object-fit: cover; }
.ranking-identity { display: grid; min-width: 0; }
.ranking-identity strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .9rem; }
.ranking-identity small { color: var(--muted); font-size: .68rem; }
.ranking-number { color: #fff; font-size: .86rem; font-weight: 950; text-align: right; }
.your-ranking { margin-top: 12px; padding: 13px 14px; border: 1px solid var(--pink); border-radius: 15px; background: rgba(124, 58, 237, .22); color: #fff; font-weight: 850; }
.your-ranking:empty { display: none; }

.result-dialog {
  width: min(430px, 100%);
  padding: 28px;
  border: 1px solid rgba(103, 232, 249, 0.58);
  border-radius: 26px;
  background: var(--surface-strong);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.5);
}

.result-dialog h2 { margin: 8px 0; font-size: 2rem; }
.result-dialog p:not(.eyebrow) { color: var(--muted); line-height: 1.5; }
.result-dialog button { width: 100%; }
.result-reason {
  padding: 12px;
  border: 1px solid rgba(103, 232, 249, .34);
  border-radius: 14px;
  background: rgba(7, 21, 15, .72);
  color: #e2e8f0 !important;
}
.result-review { display: block; margin: 0 0 14px; color: #f9a8d4; text-align: center; }

@media (max-width: 860px) {
  .game-layout { grid-template-columns: 1fr; }
  .board-frame { width: min(100%, 520px); }
  .game-panel { position: static; width: min(100%, 520px); margin: 0 auto; }
  .status-card { min-height: 0; }
}

@media (max-width: 560px) {
  .app-shell { padding-left: 8px; padding-right: 8px; }
  .game-layout { gap: 4px; }
  .topbar { align-items: center; gap: 5px; margin-bottom: 0; }
  .topbar > div:first-child > .eyebrow { display: none; }
  h1 { font-size: 1.7rem; }
  .top-actions { gap: 3px; }
  .topbar .profile-button { width: 34px; height: 34px; }
  .reaction-popup { position: fixed; top: 78px; right: 12px; }
  .icon-button { min-height: 36px; padding: 0 6px; border-radius: 11px; font-size: 0.74rem; }
  .reaction-button { min-width: 36px; font-size: 1.05rem; }
  .dot-style-button { min-width: 40px; padding-inline: 4px; font-size: .9rem; }
  #musicButton, #soundButton { min-width: 36px; font-size: .84rem; }
  .mode-strip { margin-bottom: 7px; padding: 5px; }
  .mode-button { flex: 1 1 calc(33.333% - 6px); min-height: 38px; padding: 0 8px; }
  .match-event-bar { min-height: 40px; margin-bottom: 5px; padding: 6px 10px; font-size: 1rem; }
  #modeNote { display: none; }
  .board-frame {
    width: min(100%, max(300px, calc((100dvh - 285px) * 0.86)));
    padding: 5px;
    border-radius: 24px;
  }
  .board-help { display: none; }
  .player-block-controls { margin-top: 4px; }
  .board-hint-button { min-height: 36px; padding: 0 9px; font-size: .72rem; }
  .score-row { gap: 6px; }
  .score-card { padding: 5px 8px; border-radius: 13px; }
  .score-card span { min-height: 0; font-size: 0.67rem; }
  .score-card strong { font-size: 1.25rem; }
  .player-timer { min-width: 42px; margin-top: 2px; padding: 2px 6px; font-size: .65rem; }
  .outlook-timer-row { grid-template-columns: minmax(0, 3fr) minmax(62px, 1fr); gap: 6px; }
  .outlook-card { padding: 7px 8px; border-radius: 13px; }
  .outlook-labels { margin-bottom: 5px; }
  .outlook-track { height: 8px; }
  .status-card { padding: 8px 11px; border-radius: 15px; }
  .status-card h2 { margin: 4px 0 0; font-size: 0.98rem; }
  .status-card > p:last-child { display: none; }
  .turn-timer { min-width: 62px; padding: 4px 6px; border-radius: 13px; }
  .actions { flex-direction: row; gap: 6px; }
  .actions button { min-height: 44px; padding: 0 8px; border-radius: 13px; font-size: 0.82rem; }
  .game-panel { gap: 6px; }
  .skin-feature { grid-template-columns: 1fr; }
  .skin-feature > img,
  .skin-feature .skin-board-sample { height: 164px; }
  .skin-feature > div:last-child { grid-column: 1; }
  .ranking-dialog { padding: 16px 12px; }
  .ranking-columns { top: -16px; padding-inline: 8px; }
  .ranking-row { padding-inline: 8px; }
  .ranking-player { grid-template-columns: 26px 36px minmax(0, 1fr); gap: 7px; }
  .ranking-avatar { width: 36px; height: 36px; }
  .dot-style-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
  .dot-style-choice { min-height: 96px; padding-inline: 3px; }
  .dot-style-choice strong { font-size: .7rem; }
}

@media (max-width: 420px) {
  .mode-button { padding: 0 5px; font-size: 0.71rem; }
  .board-frame { width: min(100%, 358px); }
}

@media (max-width: 360px) {
  .topbar { flex-wrap: wrap; }
  .top-actions { width: 100%; justify-content: space-between; }
  .top-actions .icon-button { flex: 0 0 auto; }
}

@media (max-height: 680px) and (min-width: 861px) {
  .board-frame { width: min(100%, 68vh, 680px); }
}

@media (orientation: landscape) and (max-height: 600px) and (pointer: coarse) {
  body { overflow: hidden; }
  .orientation-guard {
    position: fixed;
    z-index: 100;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(15, 9, 23, 0.98);
    text-align: center;
  }
  .orientation-guard > div {
    display: grid;
    gap: 10px;
    max-width: 360px;
    padding: 28px;
    border: 1px solid var(--line);
    border-radius: 24px;
    background: var(--surface);
  }
  .orientation-guard strong { color: var(--pink); font-size: 1.45rem; }
  .orientation-guard span { color: var(--muted); line-height: 1.5; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
