/* Kemalinkoo — global design system. Games add their own css in js/games/<id>/style.css */
:root {
  --ink: #2b2d42;
  --muted: #8d99ae;
  --card: #fff;
  --bg: #fff7ec;
  --line: #e9e1d6;
  --accent: #ff6b6b;
  --good: #2ec27e;
  --bad: #ff5a5f;
  --warn: #ffb703;
  --p0: #ff7a1a;
  --p1: #3a86ff;
  --radius: 22px;
  --shadow: 0 6px 18px rgba(80, 60, 30, .10), 0 1px 3px rgba(80, 60, 30, .08);
  --shadow-lg: 0 18px 50px rgba(60, 40, 20, .22);
  --font: ui-rounded, "SF Pro Rounded", "Nunito", "Varela Round", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 10%, #ffe3c2 0, transparent 32%),
    radial-gradient(circle at 92% 18%, #e4dcff 0, transparent 30%),
    radial-gradient(circle at 80% 95%, #d7f5ea 0, transparent 34%),
    var(--bg);
  background-attachment: fixed;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}
input, textarea { -webkit-user-select: text; user-select: text; font: inherit; }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: default; }
[hidden] { display: none !important; }
h1, h2, h3, h4 { margin: 0; line-height: 1.15; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }

/* ---------- buttons & chips ---------- */
.btn {
  border: 0; border-radius: 16px; padding: 12px 18px; min-height: 48px;
  font-weight: 800; font-size: 17px; background: #fff; box-shadow: var(--shadow);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .12s ease, box-shadow .12s ease, background .2s;
}
.btn:active { transform: scale(.96); }
.btn.primary { background: linear-gradient(135deg, var(--c1, #7c5cff), var(--c2, #b39dff)); color: #fff; }
.btn.ghost { background: rgba(255, 255, 255, .85); box-shadow: 0 1px 0 var(--line), 0 0 0 1.5px var(--line) inset; }
.btn.danger { background: #ffe5e6; color: #d63340; box-shadow: none; }
.btn.big { font-size: 20px; padding: 14px 24px; }
.icon-btn {
  border: 0; width: 46px; height: 46px; border-radius: 14px; background: #fff; box-shadow: var(--shadow);
  font-size: 20px; display: inline-grid; place-items: center; flex: none;
}
.icon-btn.ghost { background: transparent; box-shadow: none; }
.icon-btn:active { transform: scale(.94); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; padding: 2px 2px 8px; scrollbar-width: none; }
.chips.scroll::-webkit-scrollbar { display: none; }
.chip {
  border: 0; border-radius: 999px; padding: 10px 16px; min-height: 44px; font-weight: 700; font-size: 16px;
  background: #fff; box-shadow: 0 0 0 2px var(--line) inset; white-space: nowrap;
  transition: transform .12s, background .2s, box-shadow .2s, color .2s;
}
.chip:active { transform: scale(.95); }
.chip.on { background: var(--c1, #7c5cff); color: #fff; box-shadow: 0 4px 12px color-mix(in srgb, var(--c1, #7c5cff) 40%, transparent); }
.chip.soft { background: rgba(255, 255, 255, .8); box-shadow: 0 0 0 1.5px var(--line) inset; font-size: 15px; min-height: 38px; padding: 7px 14px; }
.chip.swap { align-self: center; background: #f4efe8; box-shadow: none; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }

/* ---------- generic screens ---------- */
.screen { min-height: 100dvh; padding: calc(var(--sat) + 14px) calc(var(--sar) + 18px) calc(var(--sab) + 24px) calc(var(--sal) + 18px); }
.topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.topbar h1 { font-size: clamp(24px, 3vw, 32px); font-weight: 900; }
.topbar-sp { flex: 1; }
.archive, .players, .settings { max-width: 1000px; margin: 0 auto; }

.empty { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty .big, .stage-msg .big { font-size: 64px; margin-bottom: 8px; }
.empty h3 { color: var(--ink); font-size: 22px; margin-bottom: 6px; }

/* ---------- HOME ---------- */
.screen.home {
  height: 100dvh; display: grid; grid-template-rows: auto auto minmax(0, 1fr); gap: clamp(8px, 1.4vh, 16px);
  padding: calc(var(--sat) + clamp(10px, 1.6vh, 20px)) calc(var(--sar) + clamp(12px, 2vw, 28px)) calc(var(--sab) + clamp(12px, 2vh, 24px)) calc(var(--sal) + clamp(12px, 2vw, 28px));
}
.home-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.logo { display: flex; align-items: center; gap: 10px; }
.logo-owl { width: clamp(48px, 6vw, 68px); aspect-ratio: 1; animation: owl 4s ease-in-out infinite; transform-origin: 50% 90%; }
.logo-owl svg { width: 100%; height: 100%; display: block; filter: drop-shadow(0 4px 6px rgba(91, 63, 214, .3)); }
.logo h1 { font-size: clamp(30px, 4.6vw, 52px); font-weight: 900; letter-spacing: -.5px; }
.logo h1 span:first-child { background: linear-gradient(90deg, #ff6b35, #f72585); -webkit-background-clip: text; background-clip: text; color: transparent; }
.logo h1 span:last-child { background: linear-gradient(90deg, #7c5cff, #3a86ff); -webkit-background-clip: text; background-clip: text; color: transparent; }
@keyframes owl { 0%, 100% { transform: rotate(-4deg); } 50% { transform: rotate(4deg); } }
.home-nav { display: flex; gap: 8px; }
.nav-btn {
  border: 0; background: #fff; border-radius: 18px; box-shadow: var(--shadow); padding: 10px 16px; min-height: 52px;
  font-size: 22px; display: flex; align-items: center; gap: 8px;
}
.nav-btn span { font-size: 16px; font-weight: 800; }
.nav-btn:active { transform: scale(.95); }
.hello { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; }
.greet { font-size: clamp(18px, 2.2vw, 24px); font-weight: 800; }
.greet span { color: var(--muted); font-weight: 700; }
.strip { display: flex; flex-wrap: wrap; gap: 8px; }

.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: repeat(3, minmax(0, 1fr)); gap: clamp(10px, 1.6vw, 20px); min-height: 0; }
.tile {
  position: relative; border: 0; border-radius: 28px; overflow: hidden; text-align: left; color: #fff;
  background: linear-gradient(150deg, var(--c1), var(--c2));
  box-shadow: 0 10px 24px color-mix(in srgb, var(--c1) 35%, transparent), inset 0 -6px 0 rgba(0, 0, 0, .08);
  display: grid; grid-template-rows: minmax(0, 1fr) auto; padding: clamp(10px, 1.4vw, 16px) clamp(12px, 1.6vw, 18px);
  transition: transform .15s cubic-bezier(.3, 1.5, .5, 1), box-shadow .15s; min-height: 0;
  animation: tileIn .5s cubic-bezier(.2, 1.3, .4, 1) both;
}
.tile:nth-child(2) { animation-delay: .04s; } .tile:nth-child(3) { animation-delay: .08s; }
.tile:nth-child(4) { animation-delay: .12s; } .tile:nth-child(5) { animation-delay: .16s; } .tile:nth-child(6) { animation-delay: .2s; }
.tile:nth-child(7) { animation-delay: .24s; } .tile:nth-child(8) { animation-delay: .28s; } .tile:nth-child(9) { animation-delay: .32s; }
@keyframes tileIn { from { opacity: 0; transform: translateY(18px) scale(.94); } }
.tile::before, .tile::after { content: ""; position: absolute; border-radius: 50%; background: rgba(255, 255, 255, .16); pointer-events: none; }
.tile::before { width: 60%; aspect-ratio: 1; right: -18%; top: -26%; }
.tile::after { width: 34%; aspect-ratio: 1; left: -10%; bottom: -14%; background: rgba(255, 255, 255, .1); }
.tile:active { transform: scale(.96); }
.tile-tag { position: absolute; left: 12px; top: 12px; z-index: 1; font-size: 12px; font-weight: 800; padding: 4px 10px; border-radius: 999px; background: rgba(255, 255, 255, .25); backdrop-filter: blur(4px); }
.tile-resume { position: absolute; right: 12px; top: 12px; z-index: 1; font-size: 13px; font-weight: 900; padding: 5px 11px; border-radius: 999px; background: #fff; color: var(--c1); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.08); } }
.tile-art { min-height: 0; display: grid; place-items: center; padding: clamp(18px, 3vh, 30px) 4% 2px; }
.tile-art svg { width: 100%; height: 100%; max-height: 100%; filter: drop-shadow(0 6px 8px rgba(0, 0, 0, .18)); transition: transform .3s; }
.tile:active .tile-art svg { transform: rotate(-4deg) scale(1.05); }
.tile-foot { display: flex; flex-direction: column; gap: 1px; position: relative; z-index: 1; }
.tile-title { font-size: clamp(18px, 2.3vw, 28px); font-weight: 900; text-shadow: 0 2px 4px rgba(0, 0, 0, .15); line-height: 1.1; }
.tile-foot small { font-size: clamp(12px, 1.3vw, 15px); font-weight: 700; opacity: .92; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@media (orientation: landscape) and (min-width: 700px) {
  .tile-art { position: absolute; inset: 10% 4% 10% 34%; padding: 0; display: flex; justify-content: flex-end; align-items: center; }
  .tile-art svg { width: auto; height: 100%; max-width: 100%; }
  .tile-foot { grid-row: 2; max-width: 62%; }
}
@media (orientation: portrait) and (min-width: 601px) {
  .tile-art { padding: 34px 2% 6px; }
}

@media (max-width: 600px) {
  .screen.home { height: auto; min-height: 100dvh; }
  .tiles { grid-template-rows: none; grid-auto-rows: 170px; }
  .nav-btn span { display: none; }
}
@media (max-height: 560px) and (min-width: 601px) {
  .screen.home { height: auto; min-height: 100dvh; }
  .tiles { grid-template-rows: none; grid-auto-rows: 180px; }
}

/* ---------- SETUP ---------- */
.setup { max-width: 1200px; margin: 0 auto; }
.setup-grid { display: grid; grid-template-columns: minmax(280px, .85fr) minmax(0, 1.15fr); gap: 20px; align-items: start; }
@media (orientation: portrait), (max-width: 860px) { .setup-grid { grid-template-columns: 1fr; } }
.setup-hero {
  position: sticky; top: 14px; border-radius: 30px; padding: 22px; color: #fff; overflow: hidden;
  background: linear-gradient(150deg, var(--c1), var(--c2)); box-shadow: 0 14px 30px color-mix(in srgb, var(--c1) 35%, transparent);
}
@media (orientation: portrait), (max-width: 860px) {
  .setup-hero { position: relative; top: 0; display: grid; grid-template-columns: 150px 1fr; column-gap: 18px; align-items: center; }
  .setup-hero .hero-art { grid-row: span 3; }
  .setup-hero .mini, .setup-hero .mini-empty { grid-column: 1 / -1; }
}
.hero-art svg { width: 100%; max-height: 220px; filter: drop-shadow(0 8px 10px rgba(0, 0, 0, .2)); }
.setup-hero h1 { font-size: clamp(30px, 4vw, 44px); font-weight: 900; margin-top: 6px; }
.setup-hero p { font-size: 19px; font-weight: 700; opacity: .95; margin: 4px 0 10px; }
.setup-hero .tag { display: inline-block; font-size: 13px; font-weight: 800; padding: 4px 12px; border-radius: 999px; background: rgba(255, 255, 255, .25); }
.mini { margin-top: 14px; background: rgba(255, 255, 255, .18); border-radius: 18px; padding: 8px 14px; }
.mini-row { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; font-size: 15px; font-weight: 700; }
.mini-row + .mini-row { border-top: 1px solid rgba(255, 255, 255, .25); }
.mini-empty { margin-top: 14px; font-weight: 700; opacity: .9; }
.setup-form { display: flex; flex-direction: column; gap: 12px; }
.sec { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; }
.sec h3 { font-size: 14px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 800; margin-bottom: 10px; }
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mode-card {
  border: 0; border-radius: 20px; padding: 14px; background: #faf6f0; box-shadow: 0 0 0 2px var(--line) inset;
  display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; transition: transform .12s, box-shadow .2s, background .2s;
}
.mode-card .mc-ico { font-size: 38px; }
.mode-card b { font-size: 18px; }
.mode-card small { color: var(--muted); font-weight: 700; }
.mode-card.on { background: color-mix(in srgb, var(--c1) 12%, #fff); box-shadow: 0 0 0 3px var(--c1) inset, 0 6px 16px color-mix(in srgb, var(--c1) 25%, transparent); }
.mode-card:active { transform: scale(.97); }
.seats { display: flex; gap: 16px; align-items: center; }
.ipad-mini {
  flex: none; width: 74px; height: 104px; border-radius: 14px; background: #2b2d42; border: 5px solid #44475e;
  display: flex; flex-direction: column; justify-content: space-between; align-items: center; padding: 4px 0; font-size: 24px;
}
.ipad-mini .im-top { transform: rotate(180deg); }
.ipad-mini .im-mid { font-size: 14px; opacity: .0; }
.seat-list { display: flex; flex-direction: column; gap: 8px; flex: 1; min-width: 0; }
.seat { display: flex; flex-direction: column; gap: 6px; }
.seat-lbl { font-weight: 800; font-size: 14px; color: var(--muted); }
.resume { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: #fff8d6; border-radius: var(--radius); padding: 14px 16px; box-shadow: 0 0 0 2px #ffe27a inset; }
.resume b { display: block; font-size: 18px; }
.resume small { color: #7a6a2a; font-weight: 700; }
.resume-act { display: flex; gap: 6px; align-items: center; }
.btn.start {
  min-height: 74px; font-size: 28px; border-radius: 24px; color: #fff; letter-spacing: .5px;
  background: linear-gradient(135deg, var(--c1), var(--c2)); box-shadow: 0 12px 26px color-mix(in srgb, var(--c1) 45%, transparent), inset 0 -5px 0 rgba(0, 0, 0, .12);
}

/* ---------- PLAY ---------- */
body[data-screen="play"] { overflow: hidden; position: fixed; inset: 0; }
.play {
  position: fixed; inset: 0; display: grid; overflow: hidden;
  padding: var(--sat) var(--sar) var(--sab) var(--sal);
}
.play.solo.two { grid-template-rows: auto auto minmax(0, 1fr) auto; grid-template-areas: "bar" "p1" "stage" "p0"; }
.play.solo.one { grid-template-rows: auto minmax(0, 1fr) auto; grid-template-areas: "bar" "stage" "p0"; }
.play.duo { grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto; grid-template-areas: "rail p1" "rail stage" "rail p0"; }
.play-bar { grid-area: bar; }
.rail { grid-area: rail; }
.panel.pn-0 { grid-area: p0; }
.panel.pn-1 { grid-area: p1; }
.stage { grid-area: stage; }

.play-bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px 2px; }
.pb-title { flex: 1; min-width: 0; display: flex; flex-direction: column; padding-left: 4px; }
.pb-name { font-size: 22px; font-weight: 900; }
.pb-status { color: var(--muted); font-weight: 700; font-size: 14px; min-height: 1.2em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tools { display: flex; gap: 8px; }
.tool-btn {
  border: 0; background: #fff; border-radius: 16px; box-shadow: var(--shadow); min-width: 54px; min-height: 52px; padding: 5px 8px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; transition: transform .12s, opacity .2s;
}
.tool-btn .ti { font-size: 22px; line-height: 1; }
.tool-btn .tl { font-size: 11px; font-weight: 800; color: var(--muted); }
.tool-btn:active { transform: scale(.93); }
.tool-btn:disabled { opacity: .35; }
.rail { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 10px 8px; background: rgba(255, 255, 255, .55); border-right: 1.5px solid var(--line); }
.rail .tools { flex-direction: column; }
.rail-sp { flex: 1; }

.panel {
  --pc: var(--p0);
  display: flex; align-items: center; gap: 10px; margin: 6px 12px; padding: 6px 10px 6px 6px; min-height: 60px;
  background: #fff; border-radius: 22px; box-shadow: var(--shadow); border: 3px solid transparent;
  transition: border-color .25s, box-shadow .25s, transform .3s;
}
.panel.rot { transform: rotate(180deg); }
.panel.is-turn { border-color: var(--pc); box-shadow: 0 0 0 5px color-mix(in srgb, var(--pc) 22%, transparent), var(--shadow); }
.pn-ava { flex: none; width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; font-size: 28px; background: color-mix(in srgb, var(--pc) 22%, #fff); }
.panel.is-turn .pn-ava { animation: bob 1.1s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-4px) rotate(-6deg); } }
.pn-txt { min-width: 0; flex: 1; }
.pn-top { display: flex; align-items: center; gap: 8px; }
.pn-name { font-weight: 900; font-size: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pn-turn { background: var(--pc); color: #fff; font-size: 13px; font-weight: 900; padding: 3px 10px; border-radius: 999px; white-space: nowrap; animation: pulse 1.4s ease-in-out infinite; }
.pn-turn:empty { display: none; }
.panel.cpu .pn-turn { background: #7b61ff; }
.pn-line { font-size: 14px; font-weight: 700; color: #6b7285; min-height: 1.25em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pn-score { flex: none; font-size: 28px; font-weight: 900; color: var(--pc); min-width: 52px; text-align: center; padding: 2px 12px; border-radius: 16px; background: color-mix(in srgb, var(--pc) 12%, #fff); }
.pn-score.bump { animation: bump .4s cubic-bezier(.3, 1.8, .5, 1); }
@keyframes bump { 40% { transform: scale(1.3); } }

.stage { position: relative; container-type: size; min-width: 0; min-height: 0; overflow: hidden; display: grid; place-items: center; }
.play.split .stage { grid-template-rows: minmax(0, 1fr) minmax(0, 1fr); place-items: stretch; }
.half { position: relative; container-type: size; min-width: 0; min-height: 0; overflow: hidden; display: grid; place-items: center; }
.half.h1 { transform: rotate(180deg); }
.half.h0 { border-top: 3px dashed color-mix(in srgb, var(--muted) 40%, transparent); }
.stage-msg { text-align: center; font-weight: 800; font-size: 20px; color: var(--muted); }

/* result overlay */
.result-layer { position: absolute; inset: 0; z-index: 30; display: none; padding: calc(var(--sat) + 16px) 16px calc(var(--sab) + 16px); background: rgba(43, 45, 66, .38); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); }
.play.show-result .result-layer { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 24px; animation: fade .3s ease; }
.play.duo.show-result .result-layer { justify-content: space-around; gap: 10px; }
@keyframes fade { from { opacity: 0; } }
.res-card {
  position: relative; width: min(560px, 100%); background: #fff; border-radius: 30px; padding: 54px 22px 18px; text-align: center;
  box-shadow: var(--shadow-lg); animation: pop .5s cubic-bezier(.2, 1.4, .4, 1) both; margin-top: 40px;
}
.res-card.rot { animation-name: popRot; transform: rotate(180deg); margin-top: 0; margin-bottom: 40px; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } }
@keyframes popRot { from { transform: rotate(180deg) scale(.6); opacity: 0; } to { transform: rotate(180deg); } }
.res-ava {
  position: absolute; left: 50%; top: -48px; translate: -50% 0; width: 96px; height: 96px; border-radius: 50%;
  display: grid; place-items: center; font-size: 56px; background: color-mix(in srgb, var(--pc) 25%, #fff); border: 5px solid #fff; box-shadow: var(--shadow);
}
.res-card.won .res-ava, .res-card.win .res-ava, .res-card.done .res-ava { animation: hop .9s ease-in-out infinite; }
@keyframes hop { 50% { transform: translateY(-8px) rotate(8deg); } }
.res-icon { position: absolute; right: -14px; bottom: -8px; font-size: 38px; }
.res-card h2 { font-size: clamp(24px, 3.4vw, 34px); font-weight: 900; }
.res-card.lost h2, .res-card.lose h2 { color: #5d6478; }
.res-sum { font-size: 18px; font-weight: 700; color: #5d6478; margin-top: 6px; }
.res-score { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 10px; font-weight: 800; flex-wrap: wrap; }
.res-score b { font-size: 30px; padding: 2px 16px; border-radius: 14px; background: #f4efe8; }
.res-extras { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; align-items: center; }
.res-chip { padding: 7px 14px; border-radius: 999px; font-weight: 800; font-size: 15px; animation: pop .5s .3s cubic-bezier(.2, 1.4, .4, 1) both; }
.res-chip.rec { background: #fff3c4; color: #8a6500; }
.res-chip.badge { background: #e9e2ff; color: #5b3fd6; }
.res-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 16px; }
.play.duo .res-card { padding: 40px 16px 12px; width: min(620px, 100%); }
.play.duo .res-ava { width: 72px; height: 72px; top: -36px; font-size: 40px; }
.play.duo .res-icon { font-size: 28px; }
.play.duo .res-card h2 { font-size: clamp(20px, 3vw, 28px); }
.play.duo .res-actions .btn { min-height: 44px; padding: 8px 12px; font-size: 15px; }
.play.duo .res-actions .btn.big { font-size: 17px; }
.peek-back { display: none; }
.play.show-result.peek .result-layer { background: transparent; backdrop-filter: none; -webkit-backdrop-filter: none; pointer-events: none; }
.play.peek .res-card { display: none; }
.play.peek .peek-back {
  display: block; pointer-events: auto; position: absolute; left: 50%; bottom: calc(var(--sab) + 90px); translate: -50% 0;
  border: 0; border-radius: 999px; padding: 14px 24px; font-size: 18px; font-weight: 900; background: var(--ink); color: #fff; box-shadow: var(--shadow-lg);
}

/* ---------- modal & toast ---------- */
#layer { position: fixed; inset: 0; pointer-events: none; z-index: 100; }
.modal-wrap {
  position: fixed; inset: 0; pointer-events: auto; display: grid; place-items: center; padding: calc(var(--sat) + 16px) 16px calc(var(--sab) + 16px);
  background: rgba(43, 45, 66, .4); opacity: 0; transition: opacity .2s;
}
.modal-wrap.in { opacity: 1; }
.modal {
  width: min(520px, 100%); max-height: calc(100dvh - 40px); overflow: auto; background: #fff; border-radius: 26px; box-shadow: var(--shadow-lg);
  transform: translateY(16px) scale(.97); transition: transform .25s cubic-bezier(.2, 1.3, .4, 1); -webkit-overflow-scrolling: touch;
}
.modal.wide { width: min(880px, 100%); }
.modal.rot { rotate: 180deg; }
.duo-toast { position: absolute; left: 50%; top: 50%; translate: -50% -50%; z-index: 25; display: flex; flex-direction: column; align-items: center; gap: 12px; pointer-events: none; opacity: 0; transition: opacity .25s; }
.duo-toast.in { opacity: 1; }
.duo-toast .dt { background: var(--ink); color: #fff; font-weight: 800; font-size: 18px; padding: 10px 20px; border-radius: 999px; box-shadow: var(--shadow-lg); white-space: nowrap; }
.duo-toast .dt.rot { transform: rotate(180deg); }
.modal-wrap.in .modal { transform: none; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 16px 0 22px; position: sticky; top: 0; background: #fff; z-index: 1; }
.modal-head h2 { font-size: 22px; font-weight: 900; }
.modal-body { padding: 12px 22px 18px; font-size: 17px; line-height: 1.5; }
.modal-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 10px; padding: 0 22px 20px; }
.confirm-msg { font-size: 19px; font-weight: 700; padding: 8px 0 4px; }
.rules h3, .rules h4 { margin: 14px 0 6px; font-size: 19px; }
.rules p { margin: 6px 0; }
.rules ul, .rules ol { margin: 6px 0; padding-left: 22px; }
.rules li { margin: 4px 0; }
.rules b, .rules strong { color: #5b3fd6; }

#toasts { position: fixed; left: 50%; top: calc(var(--sat) + 14px); translate: -50% 0; z-index: 200; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast { background: var(--ink); color: #fff; font-weight: 800; padding: 12px 20px; border-radius: 999px; box-shadow: var(--shadow-lg); opacity: 0; transform: translateY(-10px); transition: opacity .25s, transform .25s; max-width: 90vw; text-align: center; }
.toast.in { opacity: 1; transform: none; }
.toast.rot { rotate: 180deg; }
.confetti { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 300; }

/* ---------- ARCHIVE ---------- */
.tabs { display: flex; gap: 6px; background: rgba(255, 255, 255, .7); padding: 6px; border-radius: 20px; box-shadow: 0 0 0 1.5px var(--line) inset; margin-bottom: 16px; overflow-x: auto; }
.tab { flex: 1; border: 0; background: transparent; border-radius: 15px; padding: 11px 12px; font-weight: 800; font-size: 16px; white-space: nowrap; color: #5d6478; }
.tab.on { background: #fff; color: var(--ink); box-shadow: var(--shadow); }
.tab-body { display: flex; flex-direction: column; gap: 14px; --c1: #7c5cff; }
.day { margin: 10px 4px 2px; font-size: 14px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.hlist { display: flex; flex-direction: column; gap: 8px; }
.hrow { border: 0; background: #fff; border-radius: 20px; box-shadow: var(--shadow); padding: 10px 14px 10px 10px; display: flex; align-items: center; gap: 12px; text-align: left; width: 100%; }
.hrow:active { transform: scale(.99); }
.hrow-ico { flex: none; width: 58px; height: 58px; border-radius: 16px; background: linear-gradient(150deg, var(--c1), var(--c2)); display: grid; place-items: center; padding: 6px; }
.hrow-ico.big { width: 72px; height: 72px; }
.hrow-ico svg { width: 100%; height: 100%; }
.hrow-main { flex: 1; min-width: 0; }
.hrow-title { font-weight: 900; font-size: 17px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mode-badge { font-size: 12px; font-weight: 800; background: #f4efe8; color: #6b7285; padding: 2px 8px; border-radius: 999px; }
.hrow-players { display: flex; gap: 10px; flex-wrap: wrap; font-weight: 700; font-size: 15px; color: #4a5068; }
.hrow-players .w { color: var(--ink); font-weight: 900; }
.hrow-players .w::after { content: " 🏆"; }
.hrow-sum { font-size: 14px; color: var(--muted); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hrow-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; }
.hrow-side small { color: var(--muted); font-weight: 700; }
.res { font-size: 14px; font-weight: 900; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.res.win { background: #def7ea; color: #13804c; }
.res.lose { background: #ffe5e6; color: #c42d3a; }
.res.draw { background: #eef0f5; color: #5d6478; }
.more { align-self: center; }
.detail { display: flex; flex-direction: column; gap: 14px; }
.detail-head { display: flex; align-items: center; gap: 14px; }
.detail-head b { display: block; font-size: 18px; }
.detail-head small { color: var(--muted); font-weight: 700; }
.detail-players { display: flex; gap: 10px; flex-wrap: wrap; }
.dp { flex: 1; min-width: 160px; display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 18px; background: #f8f4ee; }
.dp.w { background: #fff3c4; }
.dp-ava, .ava { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-size: 26px; background: color-mix(in srgb, var(--pc, #ccc) 25%, #fff); flex: none; }
.dp-score { margin-left: auto; font-size: 22px; font-weight: 900; }
.detail-res { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-weight: 700; }
.replay-box { width: 100%; height: min(72dvh, 680px); container-type: size; position: relative; }

.h2h-big { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; }
.h2h-p { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 18px; }
.h2h-p .ava { width: 64px; height: 64px; font-size: 38px; }
.h2h-score { text-align: center; }
.h2h-score b { font-size: clamp(40px, 6vw, 60px); font-weight: 900; display: block; line-height: 1; }
.h2h-score small { color: var(--muted); font-weight: 700; }
.h2h-rows { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.h2h-row { display: grid; grid-template-columns: 140px 28px 1fr 28px; align-items: center; gap: 8px; font-weight: 800; }
.h2h-n { text-align: center; }
.bar { display: flex; height: 14px; border-radius: 999px; overflow: hidden; background: #f0ebe4; }
.bar i { display: block; height: 100%; }
.bar .bd { background: #cfd4df; }
.card h3 { font-size: 18px; margin-bottom: 10px; }
.cpu-tbl { width: 100%; border-collapse: collapse; font-weight: 700; }
.cpu-tbl th, .cpu-tbl td { padding: 9px 6px; text-align: center; border-bottom: 1px solid #f0ebe4; }
.cpu-tbl td:first-child { text-align: left; font-weight: 800; }
.wld .w { color: #13804c; }
.wld .l { color: #c42d3a; }
.tot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.tot { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 12px; border-radius: 18px; background: #f8f4ee; }
.tot small { color: #6b7285; font-weight: 700; }
.rec-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.rec-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; font-size: 18px; }
.rec-head .hrow-ico { width: 46px; height: 46px; }
.rec-row { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; padding: 7px 0; border-top: 1px solid #f0ebe4; font-weight: 700; }
.rec-row b { font-size: 18px; }
.rec-row small { color: var(--muted); }
.badge-sum { font-size: 18px; font-weight: 700; color: #5d6478; }
.badge-sum b { font-size: 26px; color: var(--ink); }
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.badge { background: #fff; border-radius: 20px; box-shadow: var(--shadow); padding: 14px 10px; text-align: center; display: flex; flex-direction: column; gap: 4px; align-items: center; }
.badge .b-ico { font-size: 40px; }
.badge b { font-size: 15px; }
.badge small { font-size: 12px; color: var(--muted); font-weight: 700; }
.badge.got { background: linear-gradient(160deg, #fffbe8, #fff); box-shadow: 0 0 0 2px #ffe27a inset, var(--shadow); }
.badge.locked { opacity: .6; filter: grayscale(1); }

/* ---------- PLAYERS ---------- */
.pl-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 14px; }
.pl { display: flex; align-items: center; gap: 16px; }
.pl-ava { border: 0; width: 84px; height: 84px; border-radius: 50%; font-size: 50px; background: color-mix(in srgb, var(--pc) 25%, #fff); box-shadow: 0 0 0 4px var(--pc); flex: none; }
.pl-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.pl-name { border: 0; background: #f8f4ee; border-radius: 14px; padding: 10px 14px; font-size: 22px; font-weight: 900; width: 100%; max-width: 360px; color: var(--ink); }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.sw { border: 0; width: 34px; height: 34px; border-radius: 50%; box-shadow: 0 0 0 2px #fff inset; }
.sw.on { box-shadow: 0 0 0 3px #fff inset, 0 0 0 3px var(--ink); }
.btn.add { width: 100%; --c1: #ff7a1a; --c2: #ffb36b; min-height: 58px; font-size: 20px; margin-bottom: 12px; }
.ava-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 8px; }
.ava-pick { border: 0; aspect-ratio: 1; border-radius: 18px; font-size: 38px; background: #f8f4ee; }
.ava-pick.on { background: #ffe9c7; box-shadow: 0 0 0 3px #ff9f1c inset; }

/* ---------- SETTINGS ---------- */
.card.set { margin-bottom: 14px; padding: 6px 18px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 0; flex-wrap: wrap; }
.set-row + .set-row { border-top: 1px solid #f0ebe4; }
.set-row b { display: block; font-size: 18px; }
.set-row small { color: var(--muted); font-weight: 700; }
.settings .chips { --c1: #7c5cff; }
.tips { padding: 16px 20px; }
.tips ul { margin: 0; padding-left: 20px; line-height: 1.55; font-size: 16px; }
.tips li { margin: 6px 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
