/* Pisti — points keeper. The whole look aims for "objects on a real table":
   wooden surface, deep green felt, paper score sheets, a plastic calculator. */

/* Table themes: wood + felt palettes, switched via body[data-theme]. */
:root {
  --wood-1: #7a5433; --wood-2: #6b4527; --wood-3: #5c3a20; --wood-4: #4e3019;
  --felt-1: #257a4c; --felt-2: #1c6440; --felt-3: #12492d; --felt-4: #0c3820;
  --rim: #5c3a20;
}
body[data-theme="mavi"] {
  --wood-1: #5a4a38; --wood-2: #4c3e2f; --wood-3: #3e3225; --wood-4: #332a1e;
  --felt-1: #2a5f92; --felt-2: #1f4a75; --felt-3: #16385c; --felt-4: #0e2846;
  --rim: #3e3225;
}
body[data-theme="bordo"] {
  --wood-1: #6b4030; --wood-2: #5c3527; --wood-3: #4e2b1f; --wood-4: #402218;
  --felt-1: #93303c; --felt-2: #7a2532; --felt-3: #601b27; --felt-4: #48121c;
  --rim: #4e2b1f;
}
body[data-theme="gece"] {
  --wood-1: #3d3d44; --wood-2: #333338; --wood-3: #28282d; --wood-4: #1e1e23;
  --felt-1: #3d4152; --felt-2: #323544; --felt-3: #272a37; --felt-4: #1d1f2a;
  --rim: #28282d;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: #2c2418;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
input, button { font: inherit; }
button { cursor: pointer; border: 0; background: none; color: inherit; }
[hidden] { display: none !important; }

/* ---- shared textures --------------------------------------------------- */
/* Wood: vertical planks + warm tones + a grain-noise SVG overlay. */
.wood, #screen-setup, #table-area {
  background:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='g'><feTurbulence type='fractalNoise' baseFrequency='0.011 0.19' numOctaves='3' seed='7'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0.35 0.25 0 0 0'/></filter><rect width='100%25' height='100%25' filter='url(%23g)' opacity='0.5'/></svg>"),
    repeating-linear-gradient(90deg,
      rgba(0,0,0,0.18) 0px, rgba(0,0,0,0) 3px,
      rgba(255,255,255,0.04) 4px, rgba(0,0,0,0) 8px,
      rgba(0,0,0,0) 118px, rgba(0,0,0,0.22) 121px),
    linear-gradient(165deg, var(--wood-1) 0%, var(--wood-2) 35%, var(--wood-3) 70%, var(--wood-4) 100%);
}

.screen { position: fixed; inset: 0; overflow: hidden; }

/* ---- update bar ---------------------------------------------------------- */
#update-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 90;
  display: flex; align-items: center; justify-content: center; gap: 12px;
  padding: 10px calc(10px + env(safe-area-inset-top)) 10px;
  padding-top: calc(10px + env(safe-area-inset-top));
  background: #1c1710ee; color: #f3ead9; font-size: 14px;
  backdrop-filter: blur(6px);
}
#update-bar button {
  background: #d8a53f; color: #241a08; font-weight: 700;
  padding: 6px 14px; border-radius: 8px;
}

/* ---- buttons ------------------------------------------------------------- */
.btn {
  display: inline-block; border-radius: 10px; font-weight: 700;
  padding: 12px 18px; transition: transform .08s, box-shadow .08s;
}
.btn:active { transform: translateY(2px); }
.btn-primary {
  background: linear-gradient(180deg, #2f8a56, #22693f);
  color: #f2fbf1; box-shadow: 0 3px 0 #17492b, 0 6px 12px rgba(0,0,0,.35);
}
.btn-primary:active { box-shadow: 0 1px 0 #17492b, 0 2px 5px rgba(0,0,0,.3); }
.btn-ghost { background: rgba(0,0,0,.08); color: #4a3a24; box-shadow: inset 0 0 0 1.5px rgba(0,0,0,.18); }

/* ====================== SETUP ============================================ */
#screen-setup { overflow: hidden; }
.setup-scroll {
  height: 100%; overflow-y: auto; padding: calc(18px + env(safe-area-inset-top)) 16px 40px;
  max-width: 560px; margin: 0 auto;
}

.brand { text-align: center; color: #f3e7cf; padding: 8px 0 18px; position: relative; }
.lang-row { position: absolute; top: 0; right: 0; display: flex; gap: 4px; z-index: 2; }
.lang-btn {
  font-size: 12px; font-weight: 800; letter-spacing: 1px; color: rgba(243,231,207,.55);
  padding: 6px 9px; border-radius: 8px; box-shadow: inset 0 0 0 1.5px rgba(243,231,207,.25);
}
.lang-btn.on { color: #2c2418; background: #f3e7cf; box-shadow: 0 2px 5px rgba(0,0,0,.35); }
.brand h1 {
  font-size: 44px; letter-spacing: 4px; font-weight: 800;
  text-shadow: 0 2px 0 rgba(0,0,0,.4), 0 6px 18px rgba(0,0,0,.45);
}
.tagline { font-size: 13px; opacity: .75; letter-spacing: 2px; text-transform: uppercase; }
.brand-cards { position: relative; height: 54px; margin-bottom: 6px; pointer-events: none; }
.bc {
  position: absolute; left: 50%; top: 4px; width: 34px; height: 46px;
  border-radius: 5px; box-shadow: 0 3px 8px rgba(0,0,0,.45);
}
.bc-back { background: #b22c30; border: 2px solid #f2e6d6; transform: translateX(-58%) rotate(-14deg); }
.bc-front {
  background: #f8f5ee; color: #c82a36; transform: translateX(-38%) rotate(9deg);
  display: flex; align-items: center; justify-content: center; font-size: 22px;
}

/* paper card panels */
.paper-form, .paper-note, .history-item {
  background:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='p'><feTurbulence type='fractalNoise' baseFrequency='0.7' numOctaves='2' seed='3'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0.05 0.05 0.02 0 0'/></filter><rect width='100%25' height='100%25' filter='url(%23p)'/></svg>"),
    linear-gradient(178deg, #faf5e9, #f1e9d6);
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(0,0,0,.25), 0 10px 24px rgba(0,0,0,.35);
}
.paper-form { padding: 20px 18px 24px; position: relative; }
.paper-form::before { /* red margin line, like a notebook */
  content: ''; position: absolute; top: 0; bottom: 0; left: 30px;
  width: 1.5px; background: rgba(217,106,106,.5); pointer-events: none;
}

.ph {
  font-size: 13px; text-transform: uppercase; letter-spacing: 2.5px;
  color: #8a7452; margin: 20px 0 10px; padding-left: 24px;
}
.ph:first-child { margin-top: 0; }
.ph-light { color: #e8dcc0; text-shadow: 0 1px 2px rgba(0,0,0,.5); padding-left: 4px; }

/* preset grid */
.preset-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; padding-left: 24px; }
.preset {
  background: linear-gradient(180deg, #fffdf6, #f3ecdb);
  border: 1.5px solid #d8ccb2; border-radius: 10px;
  padding: 12px 6px 10px; text-align: center;
  box-shadow: 0 2px 4px rgba(0,0,0,.12);
  transition: transform .12s, box-shadow .12s, border-color .12s;
}
.preset .pi { font-size: 28px; display: block; }
.preset .pn { font-size: 13px; font-weight: 700; margin-top: 4px; display: block; }
.preset .pq { font-size: 10px; color: #9a8a68; display: block; margin-top: 2px; }
.preset.on {
  border-color: #2f8a56; transform: translateY(-3px) rotate(-1deg);
  box-shadow: 0 6px 14px rgba(20,80,45,.35), inset 0 0 0 1.5px #2f8a56;
}

/* custom quick-button editor */
#custom-rows { padding-left: 24px; display: grid; gap: 8px; }
.crow { display: grid; grid-template-columns: 1fr 90px; gap: 8px; }
.crow input {
  border: 1.5px solid #d8ccb2; border-radius: 8px; padding: 9px 10px;
  background: #fffdf6; font-size: 15px;
}

/* players */
.pcount { color: #2f8a56; letter-spacing: 0; font-weight: 800; }
.stepper { display: flex; align-items: center; gap: 12px; padding-left: 24px; margin-bottom: 12px; }
.step-btn {
  width: 44px; height: 44px; border-radius: 50%;
  background: linear-gradient(180deg, #fffdf6, #eee4cd);
  border: 1.5px solid #d0c3a6; font-size: 24px; font-weight: 700; color: #5c4a2e;
  box-shadow: 0 2px 4px rgba(0,0,0,.15);
}
.step-btn:active { transform: translateY(1px); }
.pdots { flex: 1; display: flex; gap: 6px; justify-content: center; }
.pdot { width: 12px; height: 12px; border-radius: 50%; background: #ddd2b8; transition: background .15s, transform .15s; }
.pdot.on { background: #2f8a56; transform: scale(1.15); }

.player-names { padding-left: 24px; display: grid; gap: 8px; }
.pname-row { display: flex; align-items: center; gap: 10px; }
.pname-chip {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 15px;
  box-shadow: inset 0 -2px 3px rgba(0,0,0,.25), 0 2px 4px rgba(0,0,0,.2);
}
.pname-row input {
  flex: 1; border: 0; border-bottom: 1.5px dashed #c9bb9c; background: transparent;
  padding: 8px 4px; font-size: 16px; color: #2c2418;
  font-family: 'Segoe Print', 'Bradley Hand', cursive;
}
.pname-row input:focus { outline: none; border-bottom-color: #2f8a56; }

/* rules */
.rules-row { padding-left: 24px; display: flex; flex-wrap: wrap; gap: 16px; align-items: center; }
.field { display: grid; gap: 4px; font-size: 13px; color: #8a7452; }
.field input {
  width: 120px; border: 1.5px solid #d8ccb2; border-radius: 8px;
  padding: 9px 10px; background: #fffdf6; font-size: 16px;
}
.toggle { display: flex; align-items: center; gap: 8px; font-size: 14px; color: #5c4a2e; }
.toggle input { display: none; }
.knob {
  width: 42px; height: 24px; border-radius: 12px; background: #d8ccb2; position: relative;
  transition: background .15s; box-shadow: inset 0 1px 3px rgba(0,0,0,.25);
}
.knob::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px;
  border-radius: 50%; background: #fffdf6; box-shadow: 0 1px 3px rgba(0,0,0,.3);
  transition: left .15s;
}
.toggle input:checked + .knob { background: #2f8a56; }
.toggle input:checked + .knob::after { left: 20px; }

.btn-start {
  margin: 24px 0 0 24px; width: calc(100% - 24px);
  background: linear-gradient(180deg, #2f8a56, #1f5f39);
  color: #f2fbf1; font-size: 18px; letter-spacing: 1px;
  padding: 15px; border-radius: 12px;
  box-shadow: 0 4px 0 #143d24, 0 10px 20px rgba(0,0,0,.35);
}
.btn-start:active { transform: translateY(3px); box-shadow: 0 1px 0 #143d24, 0 4px 8px rgba(0,0,0,.3); }

/* resume note + history */
.paper-note {
  padding: 14px 16px; margin-bottom: 16px; transform: rotate(-.6deg);
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
}
.rn-text { display: grid; gap: 2px; font-size: 14px; }
.rn-actions { display: flex; gap: 8px; }
#history-wrap { margin-top: 26px; }
.history-item {
  width: 100%; text-align: left; padding: 12px 14px; margin-bottom: 8px;
  display: flex; justify-content: space-between; align-items: center; font-size: 14px;
}
.history-item .hw { font-weight: 800; }
.history-item .hd { color: #9a8a68; font-size: 12px; }
.setup-foot { text-align: center; color: rgba(240,225,190,.55); font-size: 12px; margin-top: 30px; letter-spacing: 1px; }

/* ====================== TABLE ============================================ */
#table-area { position: absolute; inset: 0; }

/* the felt: an inset playing surface with a wooden rim */
#felt {
  position: absolute; inset: 9% 5% 15% 5%;
  border-radius: 56px;
  background:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='f'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' seed='11'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0.08 0.04 0 0 0'/></filter><rect width='100%25' height='100%25' filter='url(%23f)'/></svg>"),
    radial-gradient(ellipse at 50% 42%, var(--felt-1) 0%, var(--felt-2) 45%, var(--felt-3) 78%, var(--felt-4) 100%);
  border: 11px solid var(--rim);
  box-shadow:
    inset 0 8px 30px rgba(0,0,0,.55),
    inset 0 -4px 18px rgba(0,0,0,.4),
    0 0 0 3px rgba(30,16,6,.8),
    0 0 0 5px rgba(150,105,60,.35),
    0 14px 34px rgba(0,0,0,.55);
}
.felt-sheen {
  position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: radial-gradient(ellipse at 38% 20%, rgba(255,255,255,.10), rgba(255,255,255,0) 55%);
}

/* center score pad (face down) */
.pad {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -58%) rotate(-3deg);
  width: min(150px, 34vw);
}
.pad-paper {
  background:
    repeating-linear-gradient(180deg, transparent 0 21px, rgba(120,140,170,.35) 21px 22.5px),
    linear-gradient(178deg, #f9f4e7, #efe6d0);
  border-radius: 4px; padding: 18px 10px 16px; text-align: center;
  box-shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 16px rgba(0,0,0,.45),
              2px 2px 0 rgba(255,255,255,.35) inset;
}
.pad-clip {
  position: absolute; top: -10px; left: 50%; transform: translateX(-50%);
  width: 46px; height: 18px; border-radius: 8px 8px 3px 3px;
  background: linear-gradient(180deg, #b8bcc4, #7e838d);
  box-shadow: 0 2px 4px rgba(0,0,0,.45), inset 0 1px 1px rgba(255,255,255,.55);
  z-index: 2;
}
.pad-game { font-size: 11px; letter-spacing: 2px; text-transform: uppercase; color: #9a8a68; }
.pad-round { font-size: 11px; letter-spacing: 3px; color: #b0a284; margin-top: 8px; }
.pad-round-num {
  font-size: 54px; line-height: 1; font-weight: 800; color: #37507a;
  font-family: 'Segoe Print', 'Bradley Hand', cursive;
  text-shadow: 1px 1px 0 rgba(0,0,0,.08);
}
.pad-progress { margin-top: 8px; display: flex; gap: 4px; justify-content: center; flex-wrap: wrap; }
.pp-dot { width: 9px; height: 9px; border-radius: 50%; background: #d9cfae; box-shadow: inset 0 1px 1px rgba(0,0,0,.15); }
.pp-dot.done { background: #2f8a56; }
.pad-pencil {
  position: absolute; right: -26px; bottom: -14px; font-size: 30px;
  transform: rotate(64deg); filter: drop-shadow(2px 3px 2px rgba(0,0,0,.4));
}

.btn-commit {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, 78px);
  background: linear-gradient(180deg, #e8973c, #c9761f);
  color: #241a08; font-weight: 800; padding: 12px 20px; border-radius: 24px;
  box-shadow: 0 3px 0 #8d5312, 0 8px 16px rgba(0,0,0,.4);
  animation: commit-in .35s cubic-bezier(.34,1.56,.64,1);
  z-index: 5;
}
.btn-commit:active { transform: translate(-50%, 80px); box-shadow: 0 1px 0 #8d5312; }
@keyframes commit-in { from { opacity: 0; transform: translate(-50%, 96px) scale(.7); } }

/* seats */
#seats { position: absolute; inset: 0; pointer-events: none; }
.seat {
  position: absolute; transform: translate(-50%, -50%);
  width: 84px; text-align: center; pointer-events: auto;
  transition: filter .2s;
}
/* geometric meeple: circle head over a stadium body, in the player color */
.seat-fig { position: relative; display: block; width: 54px; height: 56px; margin: 0 auto; transition: transform .1s; }
.fig-head {
  position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 21px; height: 21px; border-radius: 50%;
  background: var(--pc, #888);
  box-shadow: inset -2px -3px 4px rgba(0,0,0,.32), inset 2px 2px 3px rgba(255,255,255,.3),
              0 2px 4px rgba(0,0,0,.4);
  z-index: 1;
}
.fig-body {
  position: absolute; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 44px; height: 31px; border-radius: 22px 22px 8px 8px;
  background: var(--pc, #888);
  display: flex; align-items: flex-end; justify-content: center; padding-bottom: 2px;
  color: rgba(255,255,255,.9); font-weight: 800; font-size: 14px;
  box-shadow: inset 0 -4px 6px rgba(0,0,0,.3), inset 0 3px 4px rgba(255,255,255,.25),
              0 4px 10px rgba(0,0,0,.5);
}
.seat-name {
  margin-top: 5px; font-size: 12px; font-weight: 700; color: #f6eeda;
  text-shadow: 0 1px 3px rgba(0,0,0,.8); white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis;
}
/* mini card that flips when this player's score is entered */
.seat-card {
  position: absolute; top: -12px; right: 2px; width: 26px; height: 34px;
  border-radius: 4px; font-size: 15px; line-height: 34px; text-align: center;
  transition: transform .35s cubic-bezier(.34,1.56,.64,1), background .2s;
  box-shadow: 0 2px 5px rgba(0,0,0,.5);
  background: repeating-linear-gradient(45deg, #a8332f 0 4px, #922823 4px 8px);
  border: 1.5px solid #eee2ce; color: transparent; transform: rotate(8deg);
}
.seat.entered .seat-card {
  background: #f8f5ee; color: #1f5f39; font-weight: 800;
  transform: rotate(-6deg) scale(1.08);
}
.seat.pending .fig-body { animation: seat-pulse 1.6s ease-in-out infinite; }
@keyframes seat-pulse {
  0%, 100% { box-shadow: inset 0 -4px 6px rgba(0,0,0,.3), inset 0 3px 4px rgba(255,255,255,.25), 0 4px 10px rgba(0,0,0,.5); }
  50% { box-shadow: inset 0 -4px 6px rgba(0,0,0,.3), inset 0 3px 4px rgba(255,255,255,.25), 0 4px 10px rgba(0,0,0,.5), 0 0 0 5px rgba(246,220,140,.55); }
}
.seat:active .seat-fig { transform: scale(.93); }
.seat.dead { filter: grayscale(1); opacity: .55; }

/* bottom controls */
.table-controls {
  position: absolute; bottom: 0; left: 0; right: 0;
  display: flex; gap: 10px; justify-content: center; align-items: center;
  padding: 10px 16px calc(12px + env(safe-area-inset-bottom));
}
.tc-btn {
  background: rgba(20,12,4,.55); color: #f0e4c8; font-size: 17px; font-weight: 700;
  border-radius: 12px; padding: 11px 16px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.12), 0 3px 8px rgba(0,0,0,.4);
  backdrop-filter: blur(3px);
}
.tc-btn:active { transform: translateY(1px); }
.tc-finish { font-size: 15px; letter-spacing: .5px; background: rgba(90,20,16,.72); }

/* peek sheet — lift the paper corner to see running totals */
.peek-sheet {
  position: absolute; left: 50%; bottom: calc(76px + env(safe-area-inset-bottom));
  transform: translateX(-50%) rotate(1.5deg);
  background: linear-gradient(178deg, #f9f4e7, #efe6d0);
  border-radius: 6px; padding: 12px 18px; z-index: 30;
  box-shadow: 0 12px 28px rgba(0,0,0,.55);
  font-family: 'Segoe Print', 'Bradley Hand', cursive; font-size: 15px;
  animation: peek-in .18s ease-out;
}
@keyframes peek-in { from { opacity: 0; transform: translateX(-50%) translateY(14px) rotate(4deg); } }
.peek-sheet .pk-row { display: flex; justify-content: space-between; gap: 22px; padding: 2px 0; }
.peek-sheet .pk-row b { color: #37507a; }

/* round stamp animation */
.round-stamp {
  position: absolute; left: 50%; top: 42%; z-index: 40;
  transform: translate(-50%, -50%) rotate(-14deg);
  border: 4px solid #b2372f; color: #b2372f; border-radius: 10px;
  font-size: 30px; font-weight: 900; letter-spacing: 3px; padding: 10px 22px;
  text-transform: uppercase; pointer-events: none; opacity: 0;
  background: rgba(250,244,230,.06);
}
.round-stamp.go {
  animation: stamp .9s cubic-bezier(.22,1.4,.36,1) forwards;
}
@keyframes stamp {
  0% { opacity: 0; transform: translate(-50%, -50%) rotate(-14deg) scale(2.6); }
  35% { opacity: 1; transform: translate(-50%, -50%) rotate(-14deg) scale(1); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -50%) rotate(-14deg) scale(1); }
}

/* ====================== BOTTOM SHEETS ==================================== */
.sheet-overlay {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(10, 6, 2, .45);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet-overlay[hidden] { display: none !important; }

/* entry pad: paper sheet with card-like tap buttons */
.entry-sheet {
  width: min(430px, 100%);
  background:
    repeating-linear-gradient(180deg, transparent 0 25px, rgba(120,140,170,.22) 25px 26px),
    linear-gradient(178deg, #faf5e9, #efe6d0);
  border-radius: 18px 18px 0 0;
  padding: 14px 16px calc(16px + env(safe-area-inset-bottom));
  box-shadow: 0 -12px 40px rgba(0,0,0,.6);
  animation: calc-up .28s cubic-bezier(.3,1.2,.5,1);
}
.entry-sheet .calc-player { color: #2c2418; }
.entry-sheet .calc-close { color: #8a7452; }
.entry-total-row {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  border-bottom: 2px solid #8a7452; padding: 2px 4px 6px; margin-bottom: 12px;
}
.entry-tape {
  font-size: 12px; color: #9a8a68; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; min-height: 16px;
}
.entry-total {
  font-family: 'Segoe Print', 'Bradley Hand', cursive;
  font-size: 40px; line-height: 1; font-weight: 800; color: #37507a; flex: none;
}
.entry-items {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 9px; margin-bottom: 12px; max-height: 42vh; overflow-y: auto;
}
.ecard {
  position: relative; min-height: 66px; border-radius: 9px; padding: 8px 6px;
  background: linear-gradient(178deg, #fffdf6, #f0e9d8);
  border: 1.5px solid #cfc2a4;
  box-shadow: 0 2.5px 0 #b3a684, 0 4px 8px rgba(0,0,0,.12);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  transition: transform .06s, box-shadow .06s;
}
.ecard:active { transform: translateY(2px); box-shadow: 0 .5px 0 #b3a684; }
.ecard.pop .ec-label { animation: ec-pop .25s cubic-bezier(.34,1.56,.64,1); }
@keyframes ec-pop { 50% { transform: scale(1.18); } }
.ec-label { font-weight: 800; font-size: 14px; color: #2c2418; text-align: center; }
.ec-v { color: #2f8a56; font-weight: 700; font-size: 12px; margin-top: 2px; }
.ec-combo { color: #b2372f; font-size: 10px; font-weight: 700; }
.ec-count {
  position: absolute; top: -8px; right: -6px; min-width: 22px; height: 22px;
  border-radius: 11px; background: #b2372f; color: #fff; font-weight: 800;
  font-size: 13px; line-height: 22px; text-align: center; padding: 0 4px;
  box-shadow: 0 2px 5px rgba(0,0,0,.35);
}
.entry-actions { display: grid; grid-template-columns: 1fr 1fr 2fr; gap: 9px; }

/* ====================== CALCULATOR ======================================= */
.calc {
  width: min(430px, 100%);
  background: linear-gradient(172deg, #3a3d44 0%, #2b2e33 30%, #232529 100%);
  border-radius: 22px 22px 0 0;
  padding: 14px 16px calc(16px + env(safe-area-inset-bottom));
  box-shadow: 0 -12px 40px rgba(0,0,0,.6), inset 0 1.5px 0 rgba(255,255,255,.14);
  animation: calc-up .28s cubic-bezier(.3,1.2,.5,1);
}
@keyframes calc-up { from { transform: translateY(60%); opacity: .4; } }
.calc-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.calc-player { color: #e8dcc0; font-weight: 800; font-size: 16px; letter-spacing: .5px; }
.calc-player .cp-dot {
  display: inline-block; width: 12px; height: 12px; border-radius: 50%;
  margin-right: 7px; vertical-align: baseline;
}
.calc-close { color: #9aa0ab; font-size: 18px; padding: 4px 8px; }
.calc-head-btns { display: flex; gap: 2px; }
.rename-input {
  background: #1f2226; border: 1.5px solid #55606e; border-radius: 7px;
  color: #e8dcc0; font-weight: 700; font-size: 16px; padding: 4px 8px;
  width: 160px; outline: none;
}
.rename-input:focus { border-color: #e8973c; }

/* LCD */
.lcd {
  background: linear-gradient(178deg, #b8c9a4, #a7bb92);
  border-radius: 8px; padding: 8px 12px 10px; text-align: right;
  box-shadow: inset 0 3px 8px rgba(0,0,0,.5), inset 0 -1px 2px rgba(255,255,255,.3);
  border: 2px solid #1b1d20;
  margin-bottom: 12px; min-height: 74px;
}
.lcd-tape {
  font-family: ui-monospace, Menlo, monospace; font-size: 12px; color: #47523a;
  min-height: 16px; white-space: nowrap; overflow-x: hidden;
}
.lcd-total {
  font-family: ui-monospace, Menlo, monospace; font-size: 42px; line-height: 1.1;
  font-weight: 700; color: #2c3522; letter-spacing: 2px;
  text-shadow: 0 0 6px rgba(44,58,30,.25);
}

/* quick game buttons */
.quick-row { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.quick {
  flex: 1 1 0; min-width: 90px;
  background: linear-gradient(180deg, #55703f, #3e5530);
  color: #eef5df; font-weight: 700; font-size: 14px;
  border-radius: 9px; padding: 10px 6px;
  box-shadow: 0 3px 0 #26351d, inset 0 1px 0 rgba(255,255,255,.2);
  transition: transform .06s, box-shadow .06s;
}
.quick small { display: block; font-size: 11px; opacity: .8; font-weight: 600; }
.quick:active, .quick.flash { transform: translateY(2px); box-shadow: 0 1px 0 #26351d; }

/* keypad */
.keypad { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; }
.key {
  height: 56px; border-radius: 10px; font-size: 23px; font-weight: 700; color: #edeff2;
  background: linear-gradient(180deg, #4a4e57, #383c43);
  box-shadow: 0 3.5px 0 #1e2126, inset 0 1px 0 rgba(255,255,255,.16);
  transition: transform .05s, box-shadow .05s;
}
.key:active { transform: translateY(2.5px); box-shadow: 0 1px 0 #1e2126, inset 0 1px 0 rgba(255,255,255,.1); }
.key-fn { background: linear-gradient(180deg, #5c5346, #46403a); color: #f0dfc0; font-size: 20px; }
.key-fn:active { box-shadow: 0 1px 0 #26211a; }
.key-ok {
  background: linear-gradient(180deg, #e8973c, #c9761f); color: #2b1a05;
  box-shadow: 0 3.5px 0 #8d5312, inset 0 1px 0 rgba(255,255,255,.35);
  font-size: 20px; letter-spacing: 1px;
}
.key-ok:active { box-shadow: 0 1px 0 #8d5312; }

/* ====================== REVEAL =========================================== */
#screen-reveal {
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255,220,120,.14), rgba(0,0,0,0) 55%),
    linear-gradient(165deg, var(--wood-4) 0%, var(--wood-3) 60%, var(--wood-4) 100%);
}
#confetti { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 5; }
.reveal-scroll {
  position: relative; height: 100%; overflow-y: auto;
  padding: calc(26px + env(safe-area-inset-top)) 16px 40px;
  max-width: 640px; margin: 0 auto;
}

.winner-banner { text-align: center; color: #f6ecd4; margin-bottom: 20px; }
.wb-trophy {
  font-size: 74px; filter: drop-shadow(0 6px 12px rgba(0,0,0,.5));
  animation: trophy-drop .9s cubic-bezier(.34,1.56,.64,1) both;
}
@keyframes trophy-drop {
  0% { transform: translateY(-140px) scale(.4) rotate(-20deg); opacity: 0; }
  60% { transform: translateY(8px) scale(1.08) rotate(3deg); opacity: 1; }
  100% { transform: translateY(0) scale(1) rotate(0); }
}
.wb-name {
  font-size: 38px; font-weight: 900; letter-spacing: 1px;
  color: #ffd763; text-shadow: 0 2px 0 rgba(120,70,0,.6), 0 8px 22px rgba(0,0,0,.6);
  animation: name-in .7s .35s cubic-bezier(.34,1.56,.64,1) both;
}
.wb-sub { font-size: 15px; opacity: .85; margin-top: 4px; animation: name-in .7s .55s both; }
@keyframes name-in { from { opacity: 0; transform: translateY(18px) scale(.85); } }

/* the unfolding paper score sheet */
.reveal-paper {
  perspective: 1000px;
  background:
    repeating-linear-gradient(180deg, transparent 0 27px, rgba(120,140,170,.3) 27px 28.5px),
    linear-gradient(178deg, #faf5e9, #efe6d0);
  border-radius: 6px; padding: 18px 14px 22px;
  box-shadow: 0 2px 3px rgba(0,0,0,.3), 0 18px 40px rgba(0,0,0,.55);
  transform-origin: 50% 0;
  animation: unfold 1s .5s cubic-bezier(.3,1.25,.45,1) both;
  position: relative;
}
.reveal-paper::after { /* curled corner */
  content: ''; position: absolute; right: 0; bottom: 0; width: 0; height: 0;
  border-style: solid; border-width: 0 0 26px 26px;
  border-color: transparent transparent rgba(0,0,0,.14) transparent;
  border-radius: 0 0 6px 0;
}
@keyframes unfold {
  0% { transform: rotateX(-84deg); opacity: 0; }
  55% { opacity: 1; }
  75% { transform: rotateX(8deg); }
  100% { transform: rotateX(0); }
}
.rp-title {
  text-align: center; font-family: 'Segoe Print', 'Bradley Hand', cursive;
  font-size: 19px; font-weight: 700; color: #37507a; margin-bottom: 10px;
}
.rp-table-wrap { overflow-x: auto; }
#score-table { border-collapse: collapse; width: 100%; font-size: 14px; min-width: 100%; }
#score-table th, #score-table td { padding: 6px 8px; text-align: center; white-space: nowrap; }
#score-table thead th {
  font-family: 'Segoe Print', 'Bradley Hand', cursive; color: #2c2418;
  border-bottom: 2px solid #8a7452; font-size: 13px;
}
#score-table thead th .th-dot {
  display: block; width: 14px; height: 14px; border-radius: 50%; margin: 0 auto 3px;
}
#score-table td.rlabel, #score-table thead th:first-child { text-align: left; color: #9a8a68; font-size: 12px; }
#score-table tbody tr { animation: row-in .4s both; }
#score-table tbody td { border-bottom: 1px dashed rgba(138,116,82,.3); font-family: ui-monospace, Menlo, monospace; }
@keyframes row-in { from { opacity: 0; transform: translateX(-10px); } }
#score-table tfoot td {
  font-weight: 900; font-size: 17px; border-top: 2.5px solid #2c2418; padding-top: 9px;
  font-family: 'Segoe Print', 'Bradley Hand', cursive;
}
#score-table tfoot td.win { color: #b8860b; position: relative; }
#score-table tfoot td.win::before { content: '👑'; display: block; font-size: 13px; animation: crown-pop .6s 1.6s cubic-bezier(.34,1.56,.64,1) both; }
@keyframes crown-pop { from { transform: scale(0) rotate(-40deg); } }
#score-table .medal { font-size: 12px; display: block; margin-top: 1px; }

.reveal-actions { display: flex; gap: 12px; justify-content: center; margin-top: 24px; }

/* ====================== MP BUTTONS + MODAL + THEMES ====================== */
.mp-btn-row { display: grid; gap: 8px; margin: 12px 0 0 24px; }
.mp-btn { font-size: 15px; text-align: center; padding: 12px 10px; }

.modal-overlay {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(10, 6, 2, .55);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-card {
  width: min(360px, 100%);
  background: linear-gradient(178deg, #faf5e9, #f1e9d6);
  border-radius: 14px; padding: 20px 18px;
  box-shadow: 0 20px 50px rgba(0,0,0,.6);
  display: grid; gap: 14px;
  animation: modal-in .22s cubic-bezier(.3,1.3,.5,1);
}
@keyframes modal-in { from { transform: scale(.85) translateY(20px); opacity: 0; } }
.modal-card .ph { padding-left: 0; margin: 0; }
.modal-field { display: grid; gap: 5px; }
.modal-field input {
  width: 100%; border: 1.5px solid #d8ccb2; border-radius: 8px; padding: 11px 12px;
  background: #fffdf6; font-size: 17px;
}
#mp-modal-code {
  font-family: ui-monospace, Menlo, monospace; font-size: 22px;
  letter-spacing: 6px; text-align: center; font-weight: 700;
}
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }
.join-error { color: #b2372f; font-size: 13px; font-weight: 700; display: block; }

.theme-row { display: flex; gap: 12px; padding-left: 24px; }
.theme-swatch {
  width: 46px; height: 46px; border-radius: 12px;
  box-shadow: inset 0 0 0 2px rgba(0,0,0,.25), 0 2px 5px rgba(0,0,0,.25);
  transition: transform .12s;
}
.theme-swatch.on { transform: scale(1.12); box-shadow: inset 0 0 0 2px rgba(0,0,0,.25), 0 0 0 3px #2f8a56, 0 2px 5px rgba(0,0,0,.3); }
.t-yesil { background: linear-gradient(135deg, #6b4527 0 30%, #1c6440 30%); }
.t-mavi { background: linear-gradient(135deg, #4c3e2f 0 30%, #1f4a75 30%); }
.t-bordo { background: linear-gradient(135deg, #5c3527 0 30%, #7a2532 30%); }
.t-gece { background: linear-gradient(135deg, #333338 0 30%, #323544 30%); }

.lobby-paper { text-align: center; }
.lobby-game { font-size: 18px; font-weight: 800; color: #2c2418; margin: 4px 0 14px; }
.lobby-code-label, .lobby-hint {
  font-size: 12px; text-transform: uppercase; letter-spacing: 2px; color: #9a8a68;
}
.lobby-code {
  font-family: ui-monospace, Menlo, monospace; font-size: 52px; font-weight: 800;
  letter-spacing: 12px; color: #37507a; padding: 6px 0 2px;
  text-shadow: 1px 1px 0 rgba(0,0,0,.08);
}
.lobby-hint { margin-bottom: 8px; }
.lobby-players { display: grid; gap: 8px; padding: 4px 8px 0 24px; text-align: left; }
.lobby-row { display: flex; align-items: center; gap: 10px; animation: row-in .3s both; }
.lobby-name { font-size: 16px; font-weight: 700; flex: 1; font-family: 'Segoe Print', 'Bradley Hand', cursive; }
.lobby-tags { font-size: 11px; color: #9a8a68; text-transform: uppercase; letter-spacing: 1px; }
.lobby-waiting { margin: 20px 0 4px; color: #9a8a68; font-size: 14px; animation: waiting-pulse 1.8s ease-in-out infinite; }
@keyframes waiting-pulse { 50% { opacity: .45; } }
.lobby-leave { margin-top: 14px; }
#lobby-start { margin-left: 0; width: 100%; }
#lobby-start:disabled { opacity: .55; }

.mp-code-chip {
  background: rgba(20,12,4,.55); color: #f0e4c8; font-weight: 800;
  font-family: ui-monospace, Menlo, monospace; letter-spacing: 2px;
  border-radius: 12px; padding: 11px 12px; font-size: 14px;
}
.seat.me .seat-name { color: #ffd763; }

/* ====================== CUSTOM EDITOR ==================================== */
.custom-head {
  display: grid; grid-template-columns: 1.6fr 1fr 1fr 1fr 30px; gap: 8px;
  padding-left: 24px; font-size: 10px; color: #9a8a68; text-transform: uppercase;
  letter-spacing: 1px; margin-bottom: 4px;
}
#custom-rows { padding-left: 24px; display: grid; gap: 8px; }
.crow { display: grid; grid-template-columns: 1.6fr 1fr 1fr 1fr 30px; gap: 8px; align-items: center; }
.crow-del { color: #b2372f; font-weight: 800; font-size: 15px; }
.custom-add { margin: 10px 0 0 24px; font-size: 14px; padding: 9px 14px; }

/* ====================== MONOPOLY ========================================= */
.mpad .pad-paper { padding-bottom: 12px; }
.mpad-turn-label { font-size: 11px; letter-spacing: 3px; color: #b0a284; margin-top: 8px; text-transform: uppercase; }
.mpad-turn {
  font-family: 'Segoe Print', 'Bradley Hand', cursive;
  font-size: 24px; font-weight: 800; line-height: 1.2; min-height: 30px;
}
.mpad-endturn {
  margin-top: 6px; font-size: 13px; padding: 8px 12px;
  background: linear-gradient(180deg, #2f8a56, #1f5f39); color: #f2fbf1;
  box-shadow: 0 2px 0 #143d24, 0 4px 8px rgba(0,0,0,.25);
}
.mpad-log { margin-top: 10px; font-size: 10.5px; color: #8a7452; display: grid; gap: 2px; text-align: center; }
.mpad-log div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.seat-money {
  display: block; margin-top: 2px; font-size: 12px; font-weight: 800;
  color: #ffe9a8; text-shadow: 0 1px 3px rgba(0,0,0,.8); font-family: ui-monospace, Menlo, monospace;
}
.seat-jail {
  position: absolute; top: -10px; right: -4px; font-size: 18px;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,.5));
}
.seat.turn .fig-body {
  box-shadow: inset 0 -4px 6px rgba(0,0,0,.3), inset 0 3px 4px rgba(255,255,255,.25),
              0 4px 10px rgba(0,0,0,.5), 0 0 0 4px #ffd763, 0 0 18px rgba(255,215,99,.7);
}
.seat.turn .fig-head { box-shadow: inset -2px -3px 4px rgba(0,0,0,.32), 0 0 10px rgba(255,215,99,.8); }
.seat-jail b {
  font-size: 10px; background: #b2372f; color: #fff; border-radius: 8px;
  padding: 0 4px; vertical-align: top; margin-left: -3px;
}

/* monopoly action sheet */
.mono-sheet {
  width: min(430px, 100%);
  background: linear-gradient(178deg, #faf5e9, #efe6d0);
  border-radius: 18px 18px 0 0;
  padding: 14px 16px calc(16px + env(safe-area-inset-bottom));
  box-shadow: 0 -12px 40px rgba(0,0,0,.6);
  animation: calc-up .28s cubic-bezier(.3,1.2,.5,1);
  max-height: 78vh; display: flex; flex-direction: column;
}
.mono-sheet .calc-player { color: #2c2418; }
.mono-sheet .calc-close { color: #8a7452; font-size: 20px; }
.mono-body { overflow-y: auto; display: grid; gap: 9px; padding-top: 4px; }
.mono-btn {
  text-align: left; font-size: 16px; font-weight: 700; color: #2c2418;
  background: linear-gradient(178deg, #fffdf6, #f0e9d8);
  border: 1.5px solid #cfc2a4; border-radius: 10px; padding: 13px 14px;
  box-shadow: 0 2.5px 0 #b3a684;
}
.mono-btn:active { transform: translateY(2px); box-shadow: 0 .5px 0 #b3a684; }
.mono-label { font-size: 12px; text-transform: uppercase; letter-spacing: 2px; color: #9a8a68; }
.mono-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.mono-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: #fffdf6; border: 1.5px solid #cfc2a4; border-radius: 16px;
  padding: 7px 12px; font-size: 14px; font-weight: 700; color: #2c2418;
}
.mono-chip.on { border-color: #2f8a56; box-shadow: inset 0 0 0 1.5px #2f8a56; background: #eef7ee; }
.mono-amount {
  width: 100%; border: 1.5px solid #cfc2a4; border-radius: 10px; padding: 11px 12px;
  background: #fffdf6; font-size: 24px; font-weight: 700; text-align: center;
  font-family: ui-monospace, Menlo, monospace;
}
.mono-send { margin: 4px 0 0; width: 100%; }
.mono-list { display: grid; gap: 7px; }
.mono-owner {
  display: flex; align-items: center; gap: 7px; font-weight: 800; font-size: 14px;
  color: #2c2418; margin-top: 8px; border-bottom: 1.5px dashed #cfc2a4; padding-bottom: 4px;
}
.mono-prop {
  display: grid; grid-template-columns: 16px 1fr auto; align-items: center; gap: 8px;
  background: #fffdf6; border: 1px solid #e2d8c0; border-radius: 8px; padding: 8px 10px;
  font-size: 14px;
}
.mono-prop.mortgaged { opacity: .55; }
.mp-color { width: 14px; height: 22px; border-radius: 3px; box-shadow: inset 0 -2px 3px rgba(0,0,0,.25); }
.mp-name { font-weight: 700; color: #2c2418; }
.mp-rent { font-size: 12px; color: #9a8a68; white-space: nowrap; }
.mp-buy { justify-self: end; }
.mp-controls {
  grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px;
}
.mp-controls .mono-chip { font-size: 12px; padding: 5px 10px; }

/* ====================== MONO GRID / DEEDS / TRADES ======================= */
.mono-sheet { position: relative; }
.mono-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.mono-tile {
  background: linear-gradient(178deg, #fffdf6, #f0e9d8);
  border: 1.5px solid #cfc2a4; border-radius: 12px;
  padding: 13px 8px 11px; display: grid; justify-items: center; gap: 5px;
  box-shadow: 0 2.5px 0 #b3a684;
}
.mono-tile:active { transform: translateY(2px); box-shadow: 0 .5px 0 #b3a684; }
.mt-emoji { font-size: 26px; line-height: 1; }
.mt-label { font-size: 12.5px; font-weight: 800; color: #2c2418; text-align: center; line-height: 1.2; }
.mono-tile.danger { border-color: #cf8a84; }
.mono-tile.danger .mt-label { color: #b2372f; }

.deed-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.deed {
  position: relative; overflow: hidden;
  background: #fffdf6; border: 1.5px solid #cfc2a4; border-radius: 8px;
  padding: 0 3px 6px; display: grid; gap: 2px; justify-items: center;
  box-shadow: 0 2px 0 #b3a684; min-height: 72px; align-content: start;
}
.deed-band {
  width: calc(100% + 6px); height: 14px; display: block;
  box-shadow: inset 0 -2px 3px rgba(0,0,0,.25); margin-bottom: 2px;
}
.deed-name { font-size: 11.5px; font-weight: 800; color: #2c2418; text-align: center; line-height: 1.15; }
.deed-info { font-size: 9.5px; color: #9a8a68; text-align: center; }
.deed-houses { font-size: 10px; min-height: 13px; letter-spacing: -2px; }
.deed.sel { outline: 3px solid #2f8a56; outline-offset: -2px; background: #eef7ee; }
.deed.mort { opacity: .55; }

.trade-swap { text-align: center; font-size: 20px; color: #8a7452; margin: 2px 0; }
.trade-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 8px; }
.trade-actions .btn { font-size: 14px; padding: 11px 13px; }
.trade-money-line { font-weight: 800; color: #2f8a56; }
.trade-money { font-size: 17px !important; text-align: left !important; padding: 8px 12px !important; }
.bankrupt-warn { color: #b2372f; font-weight: 800; }
.mc-danger { border-color: #cf8a84; color: #b2372f; }

.mono-toast {
  position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
  background: #b2372f; color: #fff; font-weight: 800; font-size: 14px;
  padding: 8px 18px; border-radius: 18px; opacity: 0; pointer-events: none; z-index: 5;
  box-shadow: 0 6px 16px rgba(0,0,0,.4); white-space: nowrap;
}
.mono-toast.go { animation: toast-in 1.6s ease forwards; }
@keyframes toast-in {
  0% { opacity: 0; transform: translateX(-50%) translateY(-8px); }
  15% { opacity: 1; transform: translateX(-50%) translateY(0); }
  80% { opacity: 1; }
  100% { opacity: 0; }
}
.shake { animation: shake .4s; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

.mpad-trade {
  margin-top: 6px; font-size: 12px; padding: 7px 10px;
  background: linear-gradient(180deg, #e8973c, #c9761f); color: #2b1a05;
  box-shadow: 0 2px 0 #8d5312; font-weight: 800;
}
.mpad-trade.urgent { animation: waiting-pulse 1.2s ease-in-out infinite; }

/* wider screens: keep the table proportional */
@media (min-width: 700px) {
  #felt { inset: 8% 14% 14% 14%; }
}
