/* "תרגול לוח הכפל" — same design tokens as the other games in /games. */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --primary: #ff9c41; --secondary: #2a3744;
    --bg1: #0f151c; --bg2: #1b2530;
    --card-bg: rgba(18,26,34,0.92); --card-border: #223040;
    --text: #e8edf2; --muted: #8ea0ad;
    --input-bg: #1b2530;
    --good: #4ade80; --bad: #f87171; --warn: #fbbf24;
    --chip-bg: #1b2530;
    --opt-0: #ef4444; --opt-1: #3b82f6; --opt-2: #f59e0b; --opt-3: #22c55e;
}
body.light {
    --bg1: #eef1f4; --bg2: #e3e8ee;
    --card-bg: rgba(255,255,255,0.9); --card-border: rgba(0,0,0,0.08);
    --text: #15202b; --muted: rgba(21,32,43,0.65); --input-bg: rgba(255,255,255,0.9);
    --good: #16a34a; --bad: #dc2626; --warn: #d97706;
    --chip-bg: rgba(0,0,0,0.06);
}
body {
    font-family: 'Segoe UI', 'Rubik', -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
    background: linear-gradient(135deg, var(--bg1), var(--bg2)); color: var(--text);
    min-height: 100vh; line-height: 1.6; transition: background .5s;
}

.topbar { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.2rem; background: rgba(0,0,0,0.25); backdrop-filter: blur(12px); }
body.light .topbar { background: rgba(255,255,255,0.5); }
.topbar .back { color: var(--text); text-decoration: none; font-weight: 600; opacity: .9; }
.topbar .title { font-weight: 700; font-size: 1.15rem; }
.topbar-actions { display: flex; align-items: center; gap: .5rem; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; background: rgba(255,255,255,0.2); border: none; color: var(--text); font-size: 1.05rem; width: 40px; height: 40px; border-radius: 50%; cursor: pointer; transition: transform .2s; }
body.light .icon-btn { background: rgba(0,0,0,0.08); }
.icon-btn:active { transform: scale(0.9); }

#app { max-width: 540px; margin: 0 auto; padding: 1.2rem 1rem 2.5rem; }
.screen { display: none; animation: fadeIn .4s ease; }
.screen.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
.hidden { display: none !important; }

.card { background: var(--card-bg); backdrop-filter: blur(14px); border: 1px solid var(--card-border); border-radius: 22px; padding: 1.5rem 1.2rem; box-shadow: 0 18px 50px rgba(0,0,0,0.2); }
.center { text-align: center; }
.game-logo { font-size: 2.3rem; margin-bottom: .2rem; }
h2 { font-size: 1.5rem; margin-bottom: .3rem; }
h3 { font-size: 1.05rem; }
.subtitle { color: var(--muted); margin-bottom: 1.1rem; }

.banner { position: sticky; top: .6rem; z-index: 30; margin: 0 auto 1rem; max-width: 520px; padding: .7rem 1rem; border-radius: 12px; background: rgba(0,0,0,0.55); color: #fff; text-align: center; font-weight: 600; }
body.light .banner { background: rgba(30,27,75,0.9); }
.banner.error { background: var(--bad); color: #fff; }

.field-label { display: block; font-size: .9rem; color: var(--muted); font-weight: 600; margin: 1.1rem 0 .4rem; }
.text-input { width: 100%; padding: .85rem 1rem; border-radius: 12px; border: 1px solid var(--card-border); background: var(--input-bg); color: var(--text); font-size: 1.05rem; font-family: inherit; text-align: center; }
.text-input::placeholder { color: var(--muted); letter-spacing: normal; }
.code-input { letter-spacing: .45rem; font-size: 1.7rem; font-weight: 800; }

.chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip { flex: 1 1 auto; min-width: 68px; display: flex; flex-direction: column; align-items: center; gap: .1rem; padding: .6rem .7rem; border-radius: 12px; border: 2px solid transparent; background: var(--chip-bg); color: var(--text); font-family: inherit; font-size: 1rem; font-weight: 700; cursor: pointer; transition: transform .15s, border-color .2s, background .2s; }
.chip:active { transform: scale(0.96); }
.chip.active { border-color: var(--text); background: rgba(255,255,255,0.28); }
body.light .chip.active { background: rgba(255,156,65,0.18); border-color: var(--primary); }
.chip-sub { font-size: .72rem; font-weight: 500; color: var(--muted); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; width: 100%; padding: .9rem 1.3rem; border: none; border-radius: 14px; font-size: 1.05rem; font-weight: 700; cursor: pointer; font-family: inherit; text-decoration: none; transition: transform .15s, background .25s, opacity .2s; }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: #fff; color: var(--primary); box-shadow: 0 10px 26px rgba(0,0,0,0.2); }
body.light .btn-primary { background: var(--primary); color: #fff; }
.btn-secondary { background: rgba(255,255,255,0.2); color: var(--text); border: 1px solid var(--card-border); }
body.light .btn-secondary { background: rgba(0,0,0,0.05); }
.btn-small { width: auto; padding: .5rem 1rem; font-size: .9rem; }
.btn-stack { display: flex; flex-direction: column; gap: .7rem; margin-top: 1.4rem; }

/* Lobby */
.code-display { font-size: 2.6rem; font-weight: 900; letter-spacing: .5rem; padding: .6rem 0; }
.settings-line { color: var(--muted); font-size: .92rem; margin: .8rem 0; }
.roster-title { margin-top: 1rem; }
.roster { list-style: none; display: flex; flex-direction: column; gap: .4rem; margin: .6rem 0; }
.roster li { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: .55rem .9rem; border-radius: 12px; background: var(--chip-bg); font-weight: 600; }
.roster .tag { font-size: .78rem; color: var(--muted); font-weight: 500; }
.roster li.offline { opacity: .5; }
.waiting-note { color: var(--muted); text-align: center; }

/* Countdown */
.countdown-card { padding: 3rem 1.2rem; }
.countdown-number { font-size: 6rem; font-weight: 900; line-height: 1; animation: pop .5s ease; }
@keyframes pop { 0% { transform: scale(0.5); opacity: 0; } 60% { transform: scale(1.12); opacity: 1; } 100% { transform: scale(1); } }

/* Question */
.game-head { display: flex; justify-content: space-between; font-weight: 700; color: var(--muted); font-size: .95rem; }
.timer-track { height: 10px; border-radius: 999px; background: rgba(0,0,0,0.22); overflow: hidden; margin: .6rem 0 1rem; }
body.light .timer-track { background: rgba(0,0,0,0.1); }
.timer-fill { height: 100%; width: 100%; background: var(--good); transition: width .12s linear, background .3s; }
.timer-fill.hurry { background: var(--bad); }
.paused-note { text-align: center; color: var(--warn); font-weight: 700; margin-bottom: .6rem; }

.exercise { text-align: center; font-size: 3.4rem; font-weight: 900; letter-spacing: .1rem; margin: .8rem 0 1.2rem; direction: ltr; }

.options { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.option { padding: 1.15rem .6rem; border: none; border-radius: 16px; font-size: 1.7rem; font-weight: 800; color: #fff; cursor: pointer; font-family: inherit; direction: ltr; transition: transform .15s, opacity .25s, box-shadow .2s; }
.option:active { transform: scale(0.96); }
.option[data-i="0"] { background: var(--opt-0); }
.option[data-i="1"] { background: var(--opt-1); }
.option[data-i="2"] { background: var(--opt-2); }
.option[data-i="3"] { background: var(--opt-3); }
.option:disabled { cursor: default; }
.option.dimmed { opacity: .35; }
.option.picked { box-shadow: 0 0 0 4px var(--text) inset; }
.option.right { box-shadow: 0 0 0 4px #fff inset, 0 0 26px var(--good); }

/* Keypad */
.answer-display { min-height: 3.6rem; border-radius: 14px; background: rgba(0,0,0,0.2); display: flex; align-items: center; justify-content: center; font-size: 2.2rem; font-weight: 900; margin-bottom: .7rem; direction: ltr; }
body.light .answer-display { background: rgba(0,0,0,0.06); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.key { padding: .9rem 0; border: none; border-radius: 14px; background: #223040; color: var(--text); font-size: 1.5rem; font-weight: 800; font-family: inherit; cursor: pointer; transition: transform .12s; }
body.light .key { background: rgba(0,0,0,0.07); }
.key:active { transform: scale(0.94); }
.key.wide { grid-column: span 1; font-size: 1.15rem; }
.key.ok { background: var(--good); color: #06331b; }

.feedback { text-align: center; font-weight: 800; font-size: 1.1rem; min-height: 1.8rem; margin-top: .9rem; }
.feedback.good { color: var(--good); }
.feedback.bad { color: var(--bad); }

.mini-board { list-style: none; display: flex; flex-wrap: wrap; gap: .4rem; justify-content: center; margin-top: .8rem; }
.mini-board li { padding: .3rem .7rem; border-radius: 999px; background: var(--chip-bg); font-size: .85rem; font-weight: 700; }
.mini-board li.me { background: rgba(255,255,255,0.35); }
body.light .mini-board li.me { background: rgba(102,126,234,0.22); }
.mini-board li.answered::before { content: '✓ '; color: var(--good); }

/* Results */
.grade-ring { width: 132px; height: 132px; margin: .8rem auto; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 2.6rem; font-weight: 900; background: conic-gradient(var(--good) calc(var(--pct) * 1%), rgba(255,255,255,0.16) 0); position: relative; }
.grade-ring::after { content: ''; position: absolute; inset: 12px; border-radius: 50%; background: var(--card-bg); backdrop-filter: blur(6px); }
body.light .grade-ring::after { background: #fff; }
.grade-ring span { position: relative; z-index: 1; }
.grade-ring span::after { content: '%'; font-size: 1.2rem; }
.grade-line { color: var(--muted); margin-bottom: 1rem; }

/* Silver-gold-bronze left to right, the way a podium is always drawn, so the
   layout doesn't depend on how bidi resolves the flex direction. The names
   inside are Hebrew, so each step switches back to RTL. */
.podium { display: flex; direction: ltr; align-items: flex-end; justify-content: center; gap: .5rem; margin: 1.2rem 0; }
.podium .step { direction: rtl; }
.podium .step { flex: 1 1 0; max-width: 108px; border-radius: 14px 14px 0 0; background: rgba(255,255,255,0.2); padding: .6rem .3rem; display: flex; flex-direction: column; justify-content: flex-end; gap: .2rem; }
body.light .podium .step { background: rgba(102,126,234,0.16); }
.podium .step .who { font-weight: 800; font-size: .95rem; word-break: break-word; }
.podium .step .pts { font-size: .8rem; color: var(--muted); }
.podium .step .medal { font-size: 1.6rem; }
.podium .step.p1 { height: 132px; background: rgba(251,191,36,0.35); }
.podium .step.p2 { height: 106px; background: rgba(203,213,225,0.35); }
.podium .step.p3 { height: 88px; background: rgba(217,119,6,0.32); }

.standings { list-style: none; display: flex; flex-direction: column; gap: .4rem; margin: 1rem 0; text-align: right; }
.standings li { display: flex; align-items: center; gap: .6rem; padding: .55rem .9rem; border-radius: 12px; background: var(--chip-bg); }
.standings li.me { background: rgba(255,255,255,0.32); font-weight: 800; }
body.light .standings li.me { background: rgba(102,126,234,0.2); }
.standings .rank { font-weight: 900; min-width: 1.6rem; }
.standings .name { flex: 1; }
.standings .detail { color: var(--muted); font-size: .85rem; }

@media (max-width: 380px) {
    .exercise { font-size: 2.8rem; }
    .option { font-size: 1.45rem; padding: 1rem .4rem; }
}


/* ================= צוללות ================= */
:root { --sea: #1d5f9c; --sea-deep: #0c2f55; --steel: #b6c5d6; --steel-2: #8aa0b9; --hit: #dc2626; --sunk: #7f1d1d; --aim: #fde047; }
#app { max-width: 520px; }
.lbl { font-size: .78rem; font-weight: 700; color: var(--muted); }
.mode-box { display: grid; gap: .6rem; margin-top: .9rem; padding: .9rem; border-radius: 14px; background: rgba(0,0,0,.16); }
.mode-head { font-weight: 800; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.btn-sm { padding: .55rem .4rem; font-size: .9rem; }
.link-btn { background: none; border: 0; color: var(--text); text-decoration: underline; opacity: .8; font: inherit; font-size: .85rem; cursor: pointer; margin-top: .9rem; }
.how { text-align: start; margin-top: .8rem; font-size: .88rem; color: var(--muted); padding-inline-start: 1.1rem; display: grid; gap: .3rem; }

.board { display: grid; grid-template-columns: 18px repeat(var(--n, 10), 1fr); gap: 2px; direction: ltr; padding: 6px; border-radius: 12px; background: var(--sea-deep); width: 100%; }
.board.mini { grid-template-columns: repeat(var(--n, 10), 1fr); gap: 1px; padding: 4px; }
.board .h { display: grid; place-items: center; font-size: .62rem; font-weight: 700; opacity: .6; color: #fff; }
.c { position: relative; aspect-ratio: 1; padding: 0; border: 0; border-radius: 3px; appearance: none; background: var(--sea); }
.mini .c { border-radius: 2px; }
button.c { cursor: pointer; }
.c.ship { background: linear-gradient(var(--steel), var(--steel-2)); }
.c.reveal { background: rgba(182,197,214,.5); outline: 1.5px dashed rgba(255,255,255,.85); outline-offset: -2px; }
.c.miss { background-image: radial-gradient(circle at center, rgba(230,240,251,.95) 0 16%, transparent 18%); }
.c.hit { background-color: var(--hit); background-image: linear-gradient(45deg, transparent 43%, rgba(255,255,255,.95) 43% 57%, transparent 57%), linear-gradient(-45deg, transparent 43%, rgba(255,255,255,.95) 43% 57%, transparent 57%); background-size: 72% 72%; background-position: center; background-repeat: no-repeat; }
.c.sunk { background-color: var(--sunk); box-shadow: inset 0 0 0 1.5px rgba(254,202,202,.85); }
.c.last { box-shadow: inset 0 0 0 2px var(--aim); }
.c.g-ok { background: rgba(74,222,128,.85); }
.c.g-bad { background: rgba(248,113,113,.85); }
.c.aim { outline: 2px solid var(--aim); outline-offset: -2px; background-image: radial-gradient(circle at center, var(--aim) 0 12%, transparent 14%); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { outline-color: rgba(253,224,71,.35); } }
@media (prefers-reduced-motion: reduce) { .c.aim { animation: none; } .screen { animation: none; } }
.c:focus-visible, .btn:focus-visible, .chip:focus-visible { outline: 3px solid var(--aim); outline-offset: 2px; }

.tray { display: flex; gap: .4rem; margin: .6rem 0; padding: 0; list-style: none; }
.tray li { flex: 1; display: grid; place-items: center; gap: 2px; padding: .45rem .2rem; border: 2px solid transparent; border-radius: 10px; background: var(--chip-bg); font-size: .75rem; font-weight: 700; cursor: pointer; }
.tray li.cur { border-color: #fff; background: rgba(255,255,255,.26); }
.tray li.done { opacity: .55; }
.tray li.done::after { content: '\2713'; }
.pips { display: flex; gap: 2px; direction: ltr; }
.pips i { width: 9px; height: 9px; border-radius: 2px; background: var(--steel); }
.pips.sunk i { background: var(--hit); }

.strip { display: flex; align-items: baseline; justify-content: space-between; font-weight: 800; margin-bottom: .4rem; }
.strip small { font-weight: 600; opacity: .85; font-variant-numeric: tabular-nums; }
.tbar { height: 8px; overflow: hidden; border-radius: 99px; background: rgba(0,0,0,.25); margin-bottom: .6rem; }
.tbar i { display: block; height: 100%; background: var(--good); transition: width .25s linear; }
.tbar.low i { background: var(--bad); }
.cols { display: grid; grid-template-columns: 1fr 120px; gap: .6rem; align-items: start; margin-top: .6rem; }
.cols.mine-big { grid-template-columns: 1fr 120px; }
.dim { opacity: .55; }
.fleet-row { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin: .5rem 0 0; font-size: .8rem; }
.fleet-list { display: flex; gap: .6rem; flex-wrap: wrap; }
.fire { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: .7rem; margin-top: .7rem; }
.fire .aimtxt b { font-size: 1.2rem; font-variant-numeric: tabular-nums; }
.fire .btn { width: auto; min-width: 130px; }
.toast { min-height: 2.4em; margin-top: .5rem; font-weight: 700; text-align: center; }
.big-code { font-size: 2.6rem; font-weight: 900; letter-spacing: .3rem; direction: ltr; padding: .4rem 0; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin: .8rem 0; }
.stat { padding: .5rem .3rem; border-radius: 10px; background: rgba(0,0,0,.16); text-align: center; }
.stat b { display: block; font-size: 1.2rem; }
.stat span { font-size: .72rem; opacity: .8; }
.series { text-align: center; font-weight: 700; margin: .4rem 0 .8rem; }
.res-title { font-size: 1.8rem; margin: 0; }
body.light .board { background: #0c2f55; }
