:root {
  --bg: #dfe3e6;
  --text: #090a0b;
  --muted: #62686e;
  --ink: #090a0b;
  --light: #d8dce0;
  --dark: #59616a;
  --accent: #ff4b0a;
  --accent-base: #c93600;
  --card: #f3f5f6;
  --card-base: #090a0b;
  --btn: #e8ebed;
  --btn-base: #b9bec3;
  --hurt: #fff0ed;
  --hurt-base: #d8b2aa;
  --off: #c9cdd1;
  --danger: #d62f2f;
  --cream-72: rgba(9, 10, 11, 0.66);
  color-scheme: light;
}

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: Inter, Arial, sans-serif;
}

body {
  min-height: 100dvh;
  overflow-x: hidden;
}

[hidden] { display: none !important; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.platform-header { display: none; }

.platform-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-weight: 900;
  letter-spacing: -0.04em;
  text-decoration: none;
}

.platform-logo {
  width: 34px;
  height: 34px;
  display: block;
  flex: 0 0 34px;
}

.platform-brand span { font-size: 15px; }

.platform-nav { display: none; }

.platform-state {
  display: none;
}

.platform-state i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10a945;
}

.platform-state[data-state="wait"] i { background: #c9a227; }
.platform-state[data-state="off"] i { background: #d62f2f; }

.platform-geometry {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.platform-geometry i {
  position: absolute;
  display: block;
  background: rgba(9, 10, 11, 0.04);
  clip-path: polygon(0 0, 100% 0, 78% 100%, 22% 100%);
}

.platform-geometry i:nth-child(1) { width: 28vw; height: 52px; left: 24%; top: 0; }
.platform-geometry i:nth-child(2) { width: 25vw; height: 52px; left: 58%; top: 0; transform: skewX(-20deg); }
.platform-geometry i:nth-child(3) { width: 34vw; height: 110px; right: -8%; bottom: 0; transform: rotate(-18deg); }
.platform-geometry i:nth-child(4) { width: 22vw; height: 54px; left: -4%; bottom: 7%; transform: rotate(18deg); }

.layout {
  position: relative;
  z-index: 2;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  align-items: stretch;
}

.stage {
  min-width: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 8px 16px 20px;
}

.game {
  width: 100%;
  height: auto;
  min-height: 0;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.side-panel {
  position: sticky;
  top: 0;
  z-index: 5;
  width: 220px;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-self: start;
  padding: 28px 22px 24px;
  border-right: 1px solid rgba(9, 10, 11, 0.16);
  background: rgba(226, 229, 232, 0.94);
}

.side-top { order: 1; }

.menu-toggle { display: none; }

.side-menu { display: contents; }

.menu-socials { display: none; }

#invite { order: 3; }
.resign { order: 4; }
.pieces-btn { order: 5; }
.top-board { order: 6; }
.side-foot { order: 7; }

.dock {
  order: 2;
  width: 100%;
  margin-top: 36px;
}

.dock .btn:not([hidden]) ~ .btn:not([hidden]) { margin-top: 9px; }

.btn {
  --face: 44px;
  --drop: 0px;
  height: var(--face);
  width: 100%;
}

.btn-base { display: none; }

.btn-face {
  height: var(--face);
  border-radius: 0;
  font-family: "Roboto Condensed", Arial, sans-serif;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.btn-primary {
  width: 100%;
  max-width: none;
}

.btn-primary .btn-face {
  justify-content: center;
  width: 100%;
  padding: 0 18px;
  background: var(--accent);
  color: #fff;
}

#play .btn-face::before,
#retry .btn-face::before {
  content: "▶";
  margin-right: 12px;
  font-size: 9px;
}

.btn-primary:hover .btn-face { background: #df3e00; }

#invite {
  width: 100%;
  height: auto;
  margin-top: 16px !important;
}

#invite .btn-base { display: none; }

#invite .btn-face {
  position: static;
  height: auto;
  justify-content: flex-start;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 11px;
  letter-spacing: 0.12em;
}

#invite:hover .btn-face { color: var(--accent); }

#cancel {
  width: auto;
  height: auto;
}

#cancel .btn-base { display: none; }

#cancel .btn-face {
  position: static;
  height: auto;
  justify-content: flex-start;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 11px;
  letter-spacing: 0.12em;
}

#daily {
  width: 100%;
  height: auto;
  margin-top: 18px !important;
}

#daily .btn-base { display: none; }

#daily .btn-face {
  position: static;
  height: auto;
  justify-content: flex-start;
  padding: 12px 0;
  border: 0;
  border-top: 1px solid rgba(9, 10, 11, 0.16);
  border-bottom: 1px solid rgba(9, 10, 11, 0.16);
  background: transparent;
  color: var(--accent);
  font-size: 11px;
  letter-spacing: 0.14em;
}

.daily-note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-align: left;
}

.invite-box {
  margin: 0 0 10px;
  padding: 14px;
  border: 1px solid rgba(9, 10, 11, 0.18);
  background: rgba(237, 240, 242, 0.75);
}

.invite-label,
.invite-url {
  color: var(--ink);
  text-align: left;
}

.info-panel { display: none !important; }

.top-board {
  width: 100%;
  margin-top: auto;
  padding-top: 18px;
  text-align: center;
}

.top-kicker {
  margin: 0 0 8px;
  color: var(--muted);
  font-family: "Roboto Condensed", Arial, sans-serif;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.top-wrap {
  width: max-content;
  max-width: 100%;
  margin-left: auto;
  margin-right: auto;
  text-align: left;
}

.top-you {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid rgba(9, 10, 11, 0.16);
}

.top-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.top-row {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr) auto auto;
  column-gap: 8px;
  align-items: baseline;
  min-height: 20px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.65;
}

.top-rank,
.top-points,
.top-shift {
  font-variant-numeric: tabular-nums;
}

.top-rank { color: var(--muted); }

.top-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-points { text-align: right; }

.top-shift {
  min-width: 18px;
  font-size: 10px;
  font-weight: 800;
}

.top-shift.up { color: #0d8a38; }
.top-shift.down { color: var(--danger); }

.top-row.you .top-name,
.top-row.you .top-points { color: var(--accent); }

.top-empty {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.side-foot {
  margin-top: 16px;
  padding-top: 0;
}

.privacy-link {
  display: block;
  margin-top: 10px;
  color: var(--muted);
  font-family: "Roboto Condensed", Arial, sans-serif;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-align: left;
  text-decoration: none;
  text-transform: uppercase;
}

.privacy-link:hover { color: var(--ink); }

.conn {
  color: var(--ink);
  font-family: "Roboto Condensed", Arial, sans-serif;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.11em;
}

.conn-wifi {
  width: 13px;
  height: 13px;
  background: #10a945;
}

.info-copy {
  display: none;
}

.socials {
  display: none;
}

.socials a {
  height: auto;
  margin: 0;
  padding: 0;
  border-radius: 0;
  color: var(--ink);
  font-family: "Roboto Condensed", Arial, sans-serif;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.socials a:hover { background: transparent; color: var(--accent); }
.socials svg { display: none; }

.info-panel .privacy-link {
  display: none;
}

.pieces-btn {
  display: block !important;
  width: 100%;
  margin-top: 16px;
  color: var(--ink);
  font-family: "Roboto Condensed", Arial, sans-serif;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-align: left;
  text-transform: uppercase;
}

.pieces-btn:hover { color: var(--accent); }
.pieces-btn[hidden] { display: none !important; }

.lift, .sink { display: none; }

.table {
  width: min(100%, calc(100dvh - 124px));
  max-width: none;
  height: auto;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  container-type: inline-size;
}

.board {
  width: 100%;
  flex: 0 0 auto;
  overflow: hidden;
  border: 3px solid var(--ink);
  background: var(--ink);
  box-shadow: none;
}

.sq.light { background: var(--light); }
.sq.dark { background: var(--dark); }

.sq.light .coord { color: #495158; }
.sq.dark .coord { color: #dfe3e6; }

.piece {
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.2));
}

.sq.last .mark {
  background: rgba(255, 75, 10, 0.42);
  box-shadow: inset 0 0 0 3px rgba(255, 75, 10, 0.82);
}

.sq.selected,
.sq.drop-target {
  box-shadow: inset 0 0 0 4px var(--accent);
}

.sq.hint-dot .dot {
  background: rgba(255, 75, 10, 0.82);
  box-shadow: none;
}

.fx .ring,
.fx .ring.on-dark { border-color: var(--accent); }

.player,
.table .player {
  min-height: 52px;
  height: 52px;
  flex: 0 0 52px;
  box-sizing: border-box;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  padding: 0 0 0 12px;
  border-left: 4px solid transparent;
}

#me.is-active,
#opponent.is-active { border-left-color: var(--accent); }

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 0;
  filter: grayscale(1) contrast(1.25);
}

.pname {
  color: var(--ink) !important;
  font-family: "Roboto Condensed", Arial, sans-serif;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.caps img { width: 13px; height: 13px; }

.clock {
  min-width: 105px;
  min-height: 44px;
  display: grid;
  place-items: center;
  border: 2px solid var(--ink);
  background: #e9ecee;
  color: var(--ink);
}

.clock-num {
  font-family: "Roboto Condensed", Arial, sans-serif;
  font-size: min(34px, 9cqi);
  font-weight: 900;
  letter-spacing: 0;
}

.clock-bar { display: none; }

.clock.on {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.clock.low {
  border-color: #cc1f2f;
  background: #cc1f2f;
  color: #fff;
}

.waiting {
  border: 2px solid var(--ink);
  border-radius: 0;
  background: #edf0f2;
  color: var(--ink);
  font-family: "Roboto Condensed", Arial, sans-serif;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.08em;
  box-shadow: 8px 8px 0 rgba(9, 10, 11, 0.16);
  text-transform: uppercase;
}

.warning {
  color: #c42a2a;
  font-size: 11px;
}

.resign {
  align-self: flex-start;
  margin-top: 20px;
  padding: 11px 18px;
  border: 1px solid rgba(9, 10, 11, 0.45);
  color: var(--ink);
  font-family: "Roboto Condensed", Arial, sans-serif;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.1em;
}

.resign:hover { border-color: var(--danger); color: var(--danger); }

.text-btn {
  color: var(--muted);
  font-family: "Roboto Condensed", Arial, sans-serif;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.platform-footer {
  position: relative;
  z-index: 10;
  min-height: 44px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 28px;
  border-top: 1px solid rgba(9, 10, 11, 0.16);
  background: #e5e8ea;
  font-family: "Roboto Condensed", Arial, sans-serif;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.13em;
}

.platform-footer > b { font-size: 9px; }
.platform-footer nav { justify-self: end; display: flex; gap: 22px; }
.platform-footer a { color: var(--ink); text-decoration: none; }

.intro {
  background:
    linear-gradient(120deg, transparent 0 65%, rgba(255, 75, 10, 0.12) 65.2% 84%, transparent 84.2%),
    var(--bg);
}

.intro-name {
  color: var(--ink);
  font-family: "Roboto Condensed", Arial, sans-serif;
  font-size: min(14vw, 150px);
  letter-spacing: -0.04em;
  text-transform: uppercase;
}

.piece-panel,
.overlay {
  background: rgba(9, 10, 11, 0.76);
}

.piece-card {
  border: 2px solid var(--ink);
  border-radius: 0;
  background: #edf0f2;
  box-shadow: 10px 10px 0 rgba(255, 75, 10, 0.55);
}

.piece-card h2,
.card-title {
  color: var(--ink);
  font-family: "Roboto Condensed", Arial, sans-serif;
  font-weight: 900;
}

.piece-copy,
.card-copy,
.result-tag { color: var(--muted); }

.piece-row { color: var(--ink); }

.promo {
  border: 1px solid rgba(9, 10, 11, 0.22);
  border-radius: 0;
  background: #dfe3e6;
}

.card {
  padding: 0;
  border: 2px solid var(--ink);
  animation-duration: 160ms;
}

.card-base { display: none; }

.card-face {
  border-radius: 0;
  background:
    linear-gradient(135deg, transparent 0 82%, rgba(255, 75, 10, 0.12) 82.2%),
    #edf0f2;
  color: var(--ink);
}

.result-brand {
  color: var(--accent);
  font-family: "Roboto Condensed", Arial, sans-serif;
  font-weight: 900;
}

.card-title.result-title {
  color: var(--ink);
  font-family: "Roboto Condensed", Arial, sans-serif;
  font-size: 42px;
  font-weight: 900;
  text-transform: uppercase;
}

.result-detail { color: var(--ink); }

.result-actions {
  border-top-color: rgba(9, 10, 11, 0.14);
}

.card-title.loss { color: var(--danger); }

body[data-phase="playing"] .platform-geometry,
body[data-phase="waiting"] .platform-geometry {
  opacity: 0.55;
}

.ad-rail,
#ad-right {
  display: none;
}

@media (min-width: 1100px) {
  .layout {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  .game {
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: 0;
    padding: 0;
  }

  .side-panel {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    width: 220px;
    align-self: start;
  }

  .table {
    height: auto;
    width: min(100%, calc(100dvh - 124px));
    max-width: none;
    margin: 0 auto;
    justify-content: flex-start;
  }

  .table .player {
    height: 52px;
    flex: 0 0 52px;
  }
}

@media (min-width: 1480px) {
  .layout {
    grid-template-columns: 220px minmax(0, 1fr) 280px;
    padding-right: 16px;
  }

  .ad-rail,
  #ad-right {
    display: block;
    width: 280px;
    min-height: 600px;
    height: min(600px, calc(100dvh - 48px));
    align-self: center;
    background: rgba(9, 10, 11, 0.04);
  }
}

@media (max-width: 1099px) {
  body {
    --mobile-bar: calc(48px + env(safe-area-inset-top));
    --mobile-dock: 0px;
    --mobile-players: 96px;
    overflow: hidden;
  }

  .layout {
    grid-template-columns: 1fr;
    height: 100dvh;
    min-height: 100dvh;
    overflow: hidden;
  }

  .platform-footer { display: none; }

  .side-panel {
    position: relative;
    top: auto;
    width: 100%;
    height: auto;
    padding: 0;
    border-right: 0;
    border-bottom: 1px solid rgba(9, 10, 11, 0.16);
    background: #e5e8ea;
  }

  .side-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--mobile-bar);
    padding: env(safe-area-inset-top) 4px 0 14px;
  }

  .menu-toggle {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
  }

  .menu-icon,
  .menu-icon::before,
  .menu-icon::after {
    display: block;
    width: 18px;
    height: 2px;
    background: var(--ink);
    position: relative;
  }

  .menu-icon::before,
  .menu-icon::after {
    content: "";
    position: absolute;
    left: 0;
  }

  .menu-icon::before { top: -6px; }
  .menu-icon::after { top: 6px; }

  body.menu-open .menu-icon { background: transparent; }
  body.menu-open .menu-icon::before { top: 0; transform: rotate(45deg); }
  body.menu-open .menu-icon::after { top: 0; transform: rotate(-45deg); }

  .resign {
    position: absolute;
    top: calc(env(safe-area-inset-top) + 6px);
    right: 58px;
    margin: 0;
    padding: 8px 10px;
  }

  .dock {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 26;
    width: auto;
    margin: 0;
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
    background: #e5e8ea;
    border-top: 1px solid rgba(9, 10, 11, 0.16);
  }

  .dock:not(:has(> :not([hidden]))) { display: none; }

  #play,
  #retry { height: 44px; }

  #daily { margin-top: 6px !important; }

  #daily .btn-face {
    min-height: 44px;
    padding: 8px 0;
    border: 0;
  }

  .daily-note {
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .side-menu {
    display: none;
    position: fixed;
    z-index: 27;
    top: var(--mobile-bar);
    right: 0;
    bottom: 0;
    left: 0;
    flex-direction: column;
    padding: 8px 18px calc(24px + env(safe-area-inset-bottom));
    background: #e6e9eb;
    overflow: auto;
  }

  body.menu-open .side-menu { display: flex; }
  body.menu-open .dock { visibility: hidden; }

  .side-menu #invite,
  .side-menu .pieces-btn,
  .side-menu .top-board,
  .side-menu .side-foot,
  .side-menu .menu-socials {
    order: 0;
  }

  .side-menu .top-board {
    margin-top: 22px;
    padding-top: 0;
  }

  .side-menu #invite,
  .side-menu .pieces-btn {
    width: 100%;
    min-height: 48px;
    margin: 0;
    display: flex;
    align-items: center;
    border-bottom: 1px solid rgba(9, 10, 11, 0.12);
    text-align: left;
  }

  .side-menu #invite .btn-face {
    min-height: 48px;
    padding: 0;
    border: 0;
    font-size: 14px;
  }

  .side-menu .pieces-btn {
    font-size: 14px;
    letter-spacing: 0.1em;
  }

  .side-menu .side-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 18px;
    padding-top: 0;
  }

  .menu-socials {
    display: flex;
    flex-direction: column;
    margin-top: 8px;
  }

  .menu-socials a {
    min-height: 44px;
    display: flex;
    align-items: center;
    color: var(--ink);
    font-family: "Roboto Condensed", Arial, sans-serif;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-decoration: none;
    text-transform: uppercase;
  }

  .stage {
    min-height: 0;
    height: calc(100dvh - var(--mobile-bar));
    padding: 0 0 var(--mobile-dock);
    display: flex;
    align-items: center;
  }

  .game {
    height: 100%;
    justify-content: center;
  }

  .table {
    width: min(100%, calc(100dvh - var(--mobile-bar) - var(--mobile-dock) - var(--mobile-players)));
    margin: 0 auto;
  }

  .table .player {
    height: 44px;
    min-height: 44px;
    flex-basis: 44px;
    padding-left: 10px;
    padding-right: 8px;
  }

  .avatar { width: 30px; height: 30px; }
  .clock { min-width: 88px; min-height: 36px; }
  .clock-num { font-size: 26px; }
  .card-title.result-title { font-size: 34px; }
}

@media (max-width: 1099px) and (max-height: 520px) {
  body.is-home { --mobile-dock: 68px; }

  .dock {
    display: flex;
    align-items: center;
    gap: 12px;
  }

  .dock:not(:has(> :not([hidden]))) { display: none; }

  #play,
  #daily { flex: 1; margin-top: 0 !important; }

  #daily .btn-face {
    justify-content: center;
    padding: 0;
  }

  .daily-note { display: none; }
}
