/* Elyndra Chess — Copyright (c) 2026 Nahrul Kawaiiverse. All rights reserved. */
:root {
  --bg: #0d0b14; --bg2: #171424; --panel: #1f1b30; --panel2: #2a2540; --line: #3a3355;
  --gold: #e2bd62; --gold2: #b8923c; --text: #f2ecdf; --muted: #a79fb8; --good: #6fd08c; --bad: #ef6f6f;
  --light: #ecd9b4; --dark: #a5794f; --frame: #4a3222;
  --sq: calc(var(--board) / 8);
  --board: min(94vw, calc(100dvh - 300px), 620px);
  --safe-top: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif; overscroll-behavior: none; user-select: none; -webkit-user-select: none; }
body { background: radial-gradient(120% 70% at 50% -10%, #3a2a55 0%, var(--bg) 55%) fixed; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
input { font: inherit; }
.hidden { display: none !important; }
#app { max-width: 720px; margin: 0 auto; min-height: 100%; }
.screen { min-height: 100dvh; padding: calc(12px + var(--safe-top)) 14px 18px; display: flex; flex-direction: column; gap: 12px; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Home */
.logo { text-align: center; margin-top: 10px; }
.crest { font-size: 46px; color: var(--gold); text-shadow: 0 0 22px rgba(226,189,98,.55); line-height: 1; }
.logo h1 { margin: 4px 0 0; font-family: Georgia, "Times New Roman", serif; font-size: 38px; letter-spacing: 2px;
  background: linear-gradient(#fff3cf, var(--gold) 55%, var(--gold2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.logo h1 span { display: block; font-size: 17px; letter-spacing: 9px; color: var(--muted); -webkit-text-fill-color: var(--muted); margin-top: 2px; }
.tag { color: var(--muted); margin: 6px 0 0; font-size: 13px; }
.profile-card { display: flex; align-items: center; gap: 12px; text-align: left; background: linear-gradient(135deg, var(--panel2), var(--panel));
  border: 1px solid var(--line); border-radius: 16px; padding: 10px 14px; }
.profile-card img { width: 54px; height: 54px; border-radius: 12px; border: 2px solid var(--gold2); object-fit: cover; }
.pc-text { flex: 1; min-width: 0; }
.pc-text b { display: block; font-size: 17px; }
.pc-text small { color: var(--gold); font-size: 12px; }
.xpbar { height: 6px; background: #0004; border-radius: 3px; margin-top: 6px; overflow: hidden; }
.xpbar i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold2), #ffe08a); border-radius: 3px; transition: width .4s; }
.pc-rating { text-align: center; }
.pc-rating b { display: block; font-size: 22px; color: var(--gold); }
.pc-rating small { color: var(--muted); font-size: 11px; }
.menu { display: flex; flex-direction: column; gap: 9px; }
.menu .row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.menu .row button { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px 6px; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 13px; }
.menu .row .ic { font-size: 22px; }
.big { display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; padding: 13px 16px; font-size: 17px; font-weight: bold; transition: transform .1s; }
.big:active, .menu .row button:active { transform: scale(.98); }
.big .ic { font-size: 26px; width: 34px; text-align: center; }
.big small { display: block; font-weight: normal; font-size: 12px; color: var(--muted); margin-top: 2px; }
.big.gold { background: linear-gradient(135deg, #f1cf78, #b8893a); color: #24180a; border: 0; box-shadow: 0 6px 18px rgba(226,189,98,.25); }
.big.gold small { color: #4a3615; }
.foot { margin-top: auto; text-align: center; color: var(--muted); font-size: 11px; opacity: .8; }

/* Bars and lists */
.bar { display: flex; align-items: center; gap: 8px; }
.bar h2 { margin: 0; font-size: 20px; }
.back { font-size: 32px; width: 40px; height: 40px; line-height: 36px; border-radius: 12px; background: var(--panel); }
.hint { color: var(--muted); font-size: 13px; margin: 0; }
.bot-list { display: flex; flex-direction: column; gap: 8px; }
.bot { display: flex; align-items: center; gap: 12px; text-align: left; background: var(--panel); border: 2px solid transparent; border-radius: 14px; padding: 8px 12px; position: relative; }
.bot.sel { border-color: var(--gold); background: var(--panel2); }
.bot img { width: 52px; height: 52px; border-radius: 12px; object-fit: cover; }
.bot .bt { flex: 1; min-width: 0; }
.bot .bt b { display: block; font-size: 16px; }
.bot .bt small { color: var(--muted); font-size: 12px; }
.bot .br { text-align: right; font-size: 13px; color: var(--gold); }
.bot .br small { display: block; color: var(--good); font-size: 11px; }
.bot.locked { opacity: .45; }
.bot.locked img { filter: grayscale(1) brightness(.6); }
.bot .lvl { position: absolute; left: 6px; top: 6px; background: var(--gold); color: #24180a; font-size: 10px; font-weight: bold; border-radius: 6px; padding: 1px 5px; }
.bot.boss { background: linear-gradient(135deg, #3a1f3f, var(--panel)); }
.setup { display: flex; flex-direction: column; gap: 8px; background: var(--panel); border-radius: 16px; padding: 12px; position: sticky; bottom: 8px; border: 1px solid var(--line); }
.setup label { font-size: 12px; color: var(--muted); }
.setup input { background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 10px; color: var(--text); }
.seg { display: flex; background: var(--bg2); border-radius: 12px; padding: 3px; gap: 3px; flex-wrap: wrap; }
.seg button { flex: 1; padding: 9px 4px; border-radius: 9px; font-size: 13px; color: var(--muted); min-width: 60px; }
.seg button.on { background: var(--panel2); color: var(--gold); font-weight: bold; box-shadow: inset 0 0 0 1px var(--gold2); }

/* Game */
#game { position: relative; gap: 6px; padding-top: calc(8px + var(--safe-top)); }
.player { display: flex; align-items: center; gap: 10px; width: var(--board); margin: 0 auto; }
.player .av { width: 40px; height: 40px; border-radius: 10px; object-fit: cover; background: var(--panel); }
.player .pinfo { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.player .pname { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player .caps { font-size: 15px; color: var(--muted); min-height: 18px; letter-spacing: -2px; white-space: nowrap; overflow: hidden; }
.player .caps em { font-style: normal; letter-spacing: 0; font-size: 12px; margin-left: 6px; color: var(--text); }
.clock { font-family: "Courier New", monospace; font-size: 21px; font-weight: bold; background: var(--panel); border-radius: 10px; padding: 5px 10px; min-width: 84px; text-align: right; }
.clock:empty { display: none; }
.clock.on { background: #f1e4c4; color: #1b1424; }
.clock.low.on { background: var(--bad); color: #fff; }
.player.turn .pname { color: var(--gold); }
.player.thinking .pname::after { content: " …"; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }
.table .player.top { transform: rotate(180deg); }
.speech { position: absolute; z-index: 8; left: 50%; transform: translateX(-50%); top: calc(var(--safe-top) + 58px); width: min(var(--board), 92vw); box-shadow: 0 6px 18px #0007; background: #f4ecd9; color: #2a1d10; border-radius: 12px; padding: 8px 12px; font-size: 13px; position: relative; }
.speech::before { content: ""; position: absolute; top: -7px; left: 22px; border: 7px solid transparent; border-top: 0; border-bottom-color: #f4ecd9; }
.board-wrap { width: calc(var(--board) + 12px); margin: 0 auto; padding: 6px; background: var(--frame); border-radius: 10px; box-shadow: 0 10px 30px #0008, inset 0 0 0 1px #fff2; }
.board { position: relative; width: var(--board); height: var(--board); touch-action: none; border-radius: 4px; overflow: hidden; }
.sq { position: absolute; width: var(--sq); height: var(--sq); background: var(--light); }
.sq.dark { background: var(--dark); }
.sq .co { position: absolute; font-size: calc(var(--sq) * .2); font-weight: bold; opacity: .8; pointer-events: none; }
.sq .co.f { right: 3px; bottom: 1px; }
.sq .co.r { left: 3px; top: 1px; }
.sq.dark .co { color: var(--light); }
.sq:not(.dark) .co { color: var(--dark); }
.sq.last::after { content: ""; position: absolute; inset: 0; background: rgba(255, 214, 92, .42); }
.sq.sel::after { content: ""; position: absolute; inset: 0; background: rgba(255, 196, 40, .6); }
.sq.check { background: radial-gradient(circle, #ff5a4a 0%, #e0302566 45%, transparent 75%), var(--light); }
.sq.dark.check { background: radial-gradient(circle, #ff5a4a 0%, #e0302566 45%, transparent 75%), var(--dark); }
.sq.dot::before { content: ""; position: absolute; left: 35%; top: 35%; width: 30%; height: 30%; border-radius: 50%; background: rgba(20, 16, 30, .3); z-index: 1; }
.sq.ring::before { content: ""; position: absolute; inset: 4%; border-radius: 50%; border: calc(var(--sq) * .08) solid rgba(20, 16, 30, .3); z-index: 1; }
.pc { position: absolute; width: var(--sq); height: var(--sq); z-index: 2; pointer-events: none; transition: left .18s ease, top .18s ease; will-change: left, top; }
.pc img { width: 100%; height: 100%; display: block; filter: drop-shadow(0 2px 2px rgba(0,0,0,.35)); }
.pc.flipped img { transform: rotate(180deg); }
.pc.drag { transition: none; z-index: 5; transform: scale(1.15); }
.pc.gone { opacity: 0; transition: opacity .15s; }
svg.arrows { position: absolute; inset: 0; z-index: 4; pointer-events: none; }
.status { text-align: center; color: var(--muted); font-size: 13px; min-height: 18px; }
.moves { width: var(--board); margin: 0 auto; display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; padding: 2px 0; min-height: 30px; }
.moves::-webkit-scrollbar { display: none; }
.moves span { flex: none; font-size: 13px; padding: 4px 7px; border-radius: 7px; background: var(--panel); }
.moves span.n { background: none; color: var(--muted); padding: 4px 0 4px 4px; }
.moves span.cur { background: var(--gold); color: #24180a; }
.tools { width: var(--board); margin: 4px auto 0; display: flex; gap: 6px; }
.tools button { flex: 1; background: var(--panel); border-radius: 12px; padding: 7px 0 5px; font-size: 19px; display: flex; flex-direction: column; align-items: center; border: 1px solid var(--line); }
.tools button small { font-size: 10px; color: var(--muted); margin-top: 2px; }
.tools button:disabled { opacity: .35; }
.tools button:active { background: var(--panel2); }

/* Grids, lists, profile */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.pz { background: var(--panel); border-radius: 12px; padding: 12px 6px; text-align: center; border: 1px solid var(--line); }
.pz b { display: block; font-size: 18px; }
.pz small { color: var(--muted); font-size: 11px; }
.pz.done { border-color: var(--good); }
.pz.done b::after { content: " ✓"; color: var(--good); }
.list { display: flex; flex-direction: column; gap: 8px; }
.item { display: flex; align-items: center; gap: 10px; background: var(--panel); border-radius: 12px; padding: 10px 12px; text-align: left; width: 100%; }
.item .res { width: 44px; text-align: center; font-weight: bold; border-radius: 8px; padding: 4px 0; font-size: 13px; }
.res.w { background: #2f5b3c; color: #b9f3c9; } .res.l { background: #5b2f35; color: #f6c1c6; } .res.d { background: #4a4560; color: #ddd8f0; }
.item .it { flex: 1; min-width: 0; }
.item .it small { display: block; color: var(--muted); font-size: 12px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--panel); border-radius: 12px; padding: 10px 6px; text-align: center; }
.stat b { display: block; font-size: 20px; color: var(--gold); }
.stat small { color: var(--muted); font-size: 11px; }
.section-title { margin: 14px 0 6px; font-size: 14px; color: var(--gold); letter-spacing: 1px; text-transform: uppercase; }
.ach { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.ach div { background: var(--panel); border-radius: 12px; padding: 9px 10px; display: flex; gap: 9px; align-items: center; opacity: .4; }
.ach div.got { opacity: 1; border: 1px solid var(--gold2); }
.ach .ai { font-size: 22px; }
.ach b { font-size: 13px; display: block; }
.ach small { font-size: 11px; color: var(--muted); }
canvas.graph { width: 100%; height: 120px; background: var(--panel); border-radius: 12px; }
.settings { display: flex; flex-direction: column; gap: 10px; }
.opt { background: var(--panel); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.opt > span { font-size: 13px; color: var(--muted); }
.opt .swatch { display: inline-grid; grid-template-columns: 1fr 1fr; width: 26px; height: 26px; border-radius: 6px; overflow: hidden; vertical-align: middle; margin-right: 6px; }
.settings .seg button { min-width: 30%; }
.danger { background: #3b1c22; color: #ffb3b8; border-radius: 12px; padding: 12px; }

/* Modal + toast */
.modal { position: fixed; inset: 0; background: rgba(5, 3, 10, .72); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 18px; animation: fade .2s; }
.card { background: linear-gradient(160deg, var(--panel2), var(--panel)); border: 1px solid var(--gold2); border-radius: 18px; padding: 18px; width: min(420px, 100%); max-height: 90dvh; overflow-y: auto; text-align: center; box-shadow: 0 20px 50px #000a; }
.card h3 { margin: 4px 0 6px; font-size: 22px; color: var(--gold); font-family: Georgia, serif; }
.card p { color: var(--text); margin: 6px 0; font-size: 14px; }
.card .sub { color: var(--muted); font-size: 13px; }
.card .btns { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.card .btns button { background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 12px; font-weight: bold; }
.card .btns button.gold { background: linear-gradient(135deg, #f1cf78, #b8893a); color: #24180a; border: 0; }
.card img.face { width: 84px; height: 84px; border-radius: 16px; border: 2px solid var(--gold2); }
.reward { display: flex; justify-content: center; gap: 16px; margin: 10px 0; }
.reward div { background: #0003; border-radius: 10px; padding: 8px 12px; }
.reward b { display: block; font-size: 18px; color: var(--gold); }
.reward small { color: var(--muted); font-size: 11px; }
.newach { background: #0003; border-radius: 10px; padding: 6px 10px; margin: 4px 0; font-size: 13px; }
.promo { display: flex; justify-content: center; gap: 8px; }
.promo button { width: 66px; height: 66px; background: var(--light); border-radius: 12px; padding: 4px; }
.promo img { width: 100%; height: 100%; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--panel2); border: 1px solid var(--gold2); padding: 10px 16px; border-radius: 12px; z-index: 60; font-size: 14px; max-width: 90vw; text-align: center; animation: fade .2s; }
@media (min-height: 860px) { :root { --board: min(94vw, calc(100dvh - 330px), 620px); } }

.watermark { position: fixed; right: 10px; bottom: 6px; font-size: 10px; letter-spacing: 2px; text-transform: uppercase;
  color: rgba(255, 240, 210, 0.28); pointer-events: none; z-index: 70; font-weight: bold; }

/* Watch-to-claim reward (web version, games/shared/reward.js) */
.reward-btn { width: 100%; margin-top: 9px; border: 0; border-radius: 14px; padding: 12px; font-weight: 800; color: #fff; cursor: pointer;
  background: linear-gradient(135deg, #ff8fc8, #7b5cff); box-shadow: 0 6px 18px rgba(255, 143, 200, .3); }
