/* Fonts are bundled, SIL Open Font License: see fonts/OFL-*.txt */
@font-face { font-family: 'DynaPuff'; font-weight: 500; src: url(fonts/dynapuff-latin-500-normal.woff2) format('woff2'); font-display: swap; }
@font-face { font-family: 'DynaPuff'; font-weight: 700; src: url(fonts/dynapuff-latin-700-normal.woff2) format('woff2'); font-display: swap; }
@font-face { font-family: 'Lexend'; font-weight: 400; src: url(fonts/lexend-latin-400-normal.woff2) format('woff2'); font-display: swap; }
@font-face { font-family: 'Lexend'; font-weight: 600; src: url(fonts/lexend-latin-600-normal.woff2) format('woff2'); font-display: swap; }

:root {
  --plum: #3f1659; --plum-deep: #2f1045; --ink: #25082f; --lilac: #d9ccf9; --cream: #fff4e3;
  --coral: #ff6b45; --coral-d: #c23c22; --teal: #10b8a6; --teal-d: #067a72; --cookie: #dca35a; --cookie-d: #8c5420;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px); --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px);
  --display: DynaPuff, 'Arial Rounded MT Bold', 'Trebuchet MS', system-ui, sans-serif;
  --body: Lexend, 'Trebuchet MS', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none; }
html, body { margin: 0; height: 100%; overflow: hidden; position: fixed; inset: 0; width: 100%; background: var(--plum-deep); color: var(--cream); font: 400 15px/1.4 var(--body); overscroll-behavior: none; -webkit-user-select: none; user-select: none; touch-action: none; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
canvas#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
button:focus-visible { outline: 3px solid var(--cream); outline-offset: 2px; }

.icon { position: fixed; width: 44px; height: 44px; padding: 10px; background: rgba(47, 16, 69, .78); border: 0; border-radius: 50%; color: var(--cream); z-index: 3; }
.icon svg { width: 100%; height: 100%; display: block; fill: currentColor; }
#btnPause { top: calc(5px + var(--safe-t)); left: calc(5px + var(--safe-l)); }
#btnPause2 { bottom: calc(5px + var(--safe-b)); right: calc(5px + var(--safe-r)); }
#btnMute { top: calc(5px + var(--safe-t)); right: calc(5px + var(--safe-r)); }
#btnMute .off { display: none; }
#btnMute.muted .off { display: inline; }
#btnMute.muted .on { display: none; }

/* A felt patch stitched onto the table: the one button style in the game. */
.btn {
  display: block; width: 100%; padding: 11px 16px 12px; border: 0; text-align: center; color: var(--ink);
  border-radius: 16px 20px 17px 19px / 19px 16px 20px 17px; position: relative;
  background: var(--cream); box-shadow: 0 4px 0 rgba(37, 8, 47, .55);
}
.btn::after { content: ''; position: absolute; inset: 4px; border: 2px dashed rgba(37, 8, 47, .35); border-radius: inherit; pointer-events: none; }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(37, 8, 47, .55); }
.btn .t { display: block; font: 700 21px/1.15 var(--display); overflow-wrap: anywhere; }
.btn .s { display: block; font-size: 13px; line-height: 1.25; margin-top: 3px; overflow-wrap: anywhere; }
.b-coral { background: var(--coral); }
.b-teal { background: var(--teal); }
.b-cream { background: var(--cookie); }
.btn.alt { background: var(--lilac); }
.btn.quiet { background: transparent; color: var(--cream); box-shadow: none; }
.btn.quiet::after { border-color: rgba(255, 244, 227, .4); }
.btn.small { padding: 8px 12px 9px; }
.btn.small .t { font-size: 17px; }

.link { background: none; border: 0; padding: 6px 8px; min-height: 36px; color: var(--cream); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1.5px; font-size: 14px; }

/* Menu: floats over a real match being played on the table behind it. */
#menu {
  position: fixed; inset: 0; z-index: 2; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  padding: calc(10px + var(--safe-t)) calc(14px + var(--safe-r)) calc(10px + var(--safe-b)) calc(14px + var(--safe-l));
  overflow-y: auto; touch-action: pan-y; text-align: center; background: rgba(47, 16, 69, .6);
}
.menu-head { max-width: 30em; }
#logo { margin: 0; font: 700 clamp(44px, 13.5vw, 74px)/1 var(--display); color: var(--cream); letter-spacing: -.01em; text-shadow: 0 3px 0 var(--coral-d), 0 6px 0 var(--ink); overflow-wrap: anywhere; }
#tagline { margin: 8px auto 10px; font-size: 15px; line-height: 1.35; max-width: 25em; font-weight: 600; text-shadow: 0 1px 2px var(--ink); }
.menu-actions { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 10px; }
#duelCfg, #menuLinks, #stats, #byline { margin: 0; text-shadow: 0 1px 2px var(--ink); }
#duelCfg { font-size: 13px; margin-top: 4px; }
#duelCfg .link { font-size: 13px; }
#menuLinks { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; }
#langSwitch { display: inline-flex; gap: 2px; margin-left: 4px; }
.chip { border: 2px solid rgba(255, 244, 227, .55); background: transparent; color: var(--cream); border-radius: 12px; padding: 4px 10px; min-height: 34px; font-size: 13px; }
.chip[aria-pressed=true] { background: var(--cream); color: var(--ink); border-color: var(--cream); font-weight: 600; }
#stats { font-size: 12.500px; }
#byline { font-size: 11.500px; opacity: .85; max-width: 34em; }

@media (orientation: landscape) and (max-height: 500px) {
  #menu { justify-content: flex-start; gap: 3px; padding-top: calc(4px + var(--safe-t)); padding-bottom: 4px; }
  .menu-head { display: flex; align-items: baseline; gap: 14px; max-width: none; }
  #logo { font-size: 36px; text-shadow: 0 2px 0 var(--coral-d), 0 3px 0 var(--ink); }
  #tagline { margin: 0; font-size: 12px; text-align: left; }
  .menu-actions { flex-direction: row; max-width: 760px; gap: 8px; align-items: stretch; }
  .btn.big { padding: 7px 8px 8px; }
  .btn.big .t { font-size: 17px; }
  .btn.big .s { font-size: 11.500px; }
  #stats, #byline { font-size: 11px; }
  .link { min-height: 30px; padding: 3px 8px; font-size: 13px; }
  .chip { min-height: 28px; padding: 2px 8px; }
  #duelCfg { margin-top: 3px; }
}
@media (orientation: portrait) and (max-height: 600px) {
  #logo { font-size: 40px; }
  #tagline { font-size: 13px; margin: 4px auto 6px; }
  .btn.big { padding: 7px 12px 8px; }
  .btn.big .t { font-size: 18px; }
  .btn.big .s { font-size: 12px; }
  .menu-actions { gap: 7px; }
}

/* Panels */
#panel { position: fixed; inset: 0; z-index: 4; display: flex; align-items: center; justify-content: center; padding: 10px; background: rgba(47, 16, 69, .72); }
.card {
  width: 100%; max-width: 460px; max-height: 100%; overflow-y: auto; touch-action: pan-y; background: var(--plum); border-radius: 20px 24px 21px 23px;
  padding: 16px 18px; box-shadow: 0 8px 0 rgba(37, 8, 47, .6); outline: 2px dashed rgba(255, 244, 227, .3); outline-offset: -7px; text-align: center;
}
.card h2 { margin: 2px 0 8px; font: 700 28px/1.1 var(--display); color: var(--cream); overflow-wrap: anywhere; }
#pBody { font-size: 15px; }
#pBody p { margin: 6px 0; }
#pBody .big-score { font: 700 58px/1 var(--display); color: var(--cookie); margin: 4px 0; }
#pBody .note { font-size: 13px; opacity: .9; }
#pBody .new { font-weight: 600; color: #ffd98a; }
#pBtns { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
#pToast { min-height: 1.2em; margin: 6px 0 0; font-size: 13px; }
#pToast:empty { display: none; }
.how { text-align: left; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 4px 0 10px; }
.chips-label { font-weight: 600; margin: 8px 0 2px; }
.starline { font: 700 26px/1 var(--display); color: #ffd98a; letter-spacing: .08em; }
.starline .off { opacity: .28; }
.pre-share { width: 100%; font: 13px/1.35 var(--body); background: var(--plum-deep); color: var(--cream); border: 0; border-radius: 10px; padding: 8px; height: 5.5em; resize: none; -webkit-user-select: text; user-select: text; }

/* Ladder and pets */
.rows { display: flex; flex-direction: column; gap: 7px; text-align: left; margin-top: 8px; }
.row { display: flex; gap: 10px; align-items: center; width: 100%; padding: 6px 10px 6px 6px; background: var(--plum-deep); border: 0; border-radius: 14px; color: var(--cream); text-align: left; min-height: 62px; }
.row[disabled] { opacity: .78; cursor: default; }
.row:not([disabled]):active { transform: translateY(2px); }
.row.current { outline: 2px solid var(--cookie); outline-offset: -2px; }
.row canvas { width: 62px; height: 50px; flex: none; }
.row .n { display: block; font: 700 16px/1.2 var(--display); overflow-wrap: anywhere; }
.row .d { display: block; font-size: 12.500px; line-height: 1.25; opacity: .9; }
.row .st { margin-left: auto; flex: none; font: 700 15px/1 var(--display); color: #ffd98a; white-space: nowrap; }

/* A result panel for each end of the table, turned to face its own player. game.js places and rotates them. */
.face {
  position: fixed; z-index: 3; left: 50%; top: 50%; padding: 12px 16px 12px; text-align: center; display: flex; flex-direction: column; justify-content: center; gap: 6px;
  background: rgba(63, 22, 89, .95); border-radius: 22px 26px 24px 28px; outline: 2px dashed rgba(255, 244, 227, .3); outline-offset: -6px; overflow: hidden; touch-action: manipulation;
}
.face h2 { margin: 0; font: 700 clamp(24px, 7.500vmin, 40px)/1.05 var(--display); overflow-wrap: anywhere; }
.face.won h2 { color: #ffd98a; }
.face p { margin: 0; font-size: clamp(12.500px, 3.500vmin, 15px); line-height: 1.28; }
.face .small { font-size: clamp(11.500px, 3vmin, 13px); opacity: .9; }
.face .btn .t { font-size: clamp(16px, 5vmin, 21px); }
.face .btn { padding: 8px 12px 9px; }
.face .acts { display: flex; flex-direction: column; gap: 6px; }
.face .link { min-height: 30px; padding: 2px 6px; font-size: clamp(12px, 3.200vmin, 14px); }
.face .links { display: flex; justify-content: center; flex-wrap: wrap; }

@media (prefers-reduced-motion: reduce) { .btn:active, .row:active { transform: none; } }
