/* Ghicește codul — the colour code-breaking game (js/ghiceste-codul.js).
   Theme-aware like the other game pages: tokens on :root, redefined under body.dark-theme. */
:root {
    --gc-accent: #1d4ed8;
    --gc-accent-ink: #ffffff;
    --gc-accent-soft: #dbeafe;
    --gc-page-bg: #eef2f8;
    --gc-card-bg: #ffffff;
    --gc-card-border: #d8e0ec;
    --gc-muted: #55627a;
    --gc-shadow: 0 10px 30px rgba(20, 40, 90, .10);
    --gc-board: #f4f1ea;
    --gc-board-border: #e1d9c8;
    --gc-hole: #d9d0bd;
    --gc-hole-in: #c9bea7;
    --gc-row-active: #fff8e1;
    --gc-good: #15803d;
    --gc-bad: #dc2626;
    --gc-fb-black: #111827;
    --gc-fb-white: #ffffff;
    --gc-fb-ring: #6b7280;
    --gc-c0: #dc2626; --gc-i0: #ffffff;
    --gc-c1: #2563eb; --gc-i1: #ffffff;
    --gc-c2: #16a34a; --gc-i2: #ffffff;
    --gc-c3: #facc15; --gc-i3: #422006;
    --gc-c4: #f97316; --gc-i4: #431407;
    --gc-c5: #9333ea; --gc-i5: #ffffff;
    --gc-c6: #06b6d4; --gc-i6: #083344;
    --gc-c7: #ec4899; --gc-i7: #ffffff;
}

body.dark-theme {
    --gc-accent: #60a5fa;
    --gc-accent-ink: #0b1a33;
    --gc-accent-soft: #172a4a;
    --gc-page-bg: #0d1220;
    --gc-card-bg: #161d2e;
    --gc-card-border: #2a3550;
    --gc-muted: #a3b0c8;
    --gc-shadow: 0 10px 30px rgba(0, 0, 0, .45);
    --gc-board: #1f2638;
    --gc-board-border: #303a54;
    --gc-hole: #2c3550;
    --gc-hole-in: #222a40;
    --gc-row-active: #2a2f45;
    --gc-good: #4ade80;
    --gc-bad: #f87171;
    --gc-fb-black: #05070d;
    --gc-fb-white: #f8fafc;
    --gc-fb-ring: #94a3b8;
}

/* clip, not hidden: the site-wide `body { overflow-x: hidden }` would kill position: sticky
   (the palette sticks to the bottom of the screen while the board scrolls). */
.gc-body, body.gc-body#page-top {
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    background: var(--gc-page-bg);
    color: var(--text-color);
    min-height: 100vh;
    overflow-x: clip;
}
.gc-main { padding-top: 96px; padding-bottom: 40px; }
.gc-wrap { max-width: 560px; }

.gc-head { text-align: center; margin-bottom: 8px; }
.gc-head h1 { font-weight: 800; font-size: clamp(1.7rem, 6vw, 2.3rem); margin: 0 0 2px; }
.gc-lead { color: var(--gc-muted); margin: 0 auto; max-width: 32em; line-height: 1.45; }

.gc-modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; padding: 5px; margin: 8px 0 10px; border-radius: 16px; background: var(--gc-card-bg); border: 1px solid var(--gc-card-border); }
.gc-seg { min-height: 48px; padding: 6px 6px; border: 0; border-radius: 12px; background: transparent; color: inherit; font-weight: 700; font-size: .88rem; line-height: 1.15; cursor: pointer; touch-action: manipulation; display: flex; align-items: center; justify-content: center; gap: 6px; text-align: center; }
.gc-seg[aria-checked="true"] { background: var(--gc-accent); color: var(--gc-accent-ink); }

.gc-duo { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0 0 10px; }
.gc-duo[hidden] { display: none; }
.gc-duo-p { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto auto; column-gap: 8px; align-items: center; padding: 7px 12px; border-radius: 14px; background: var(--gc-card-bg); border: 2px solid var(--gc-card-border); }
.gc-duo-p.is-maker { border-color: var(--gc-accent); }
.gc-duo-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gc-duo-p small { grid-row: 2; color: var(--gc-muted); font-size: .75rem; }
.gc-duo-p b { grid-row: 1 / 3; grid-column: 2; font-size: 1.35rem; color: var(--gc-accent); font-variant-numeric: tabular-nums; }

/* ---- play card ---- */
.gc-play { --gc-pegs: 4; --peg: 38px; position: relative; padding: 12px 12px 0; border-radius: 20px; background: var(--gc-card-bg); border: 1px solid var(--gc-card-border); box-shadow: var(--gc-shadow); }
.gc-play.is-five { --peg: 34px; }
.gc-status { text-align: center; min-height: 54px; padding: 0 4px 6px; }
.gc-status-main { font-weight: 800; font-size: 1.12rem; line-height: 1.25; }
.gc-status-sub { color: var(--gc-muted); font-weight: 600; font-size: .9rem; min-height: 1.3em; line-height: 1.35; }
.gc-status-sub.is-bad { color: var(--gc-bad); }

.gc-secret { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 8px 10px; margin: 0 0 8px; border-radius: 14px; background: color-mix(in srgb, var(--gc-accent) 10%, var(--gc-board)); border: 1px solid var(--gc-board-border); }
.gc-secret.is-active { background: var(--gc-row-active); border-color: var(--gc-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--gc-accent) 20%, transparent); }
.gc-secret-label { font-weight: 800; font-size: .82rem; text-transform: uppercase; letter-spacing: .05em; color: var(--gc-muted); }
.gc-pegs { display: flex; gap: 6px; align-items: center; }
.gc-hole.is-hidden { width: var(--peg); height: var(--peg); border-radius: 50%; display: grid; place-items: center; background: var(--gc-hole-in); color: var(--gc-muted); font-weight: 800; box-shadow: inset 0 2px 4px rgba(0, 0, 0, .18); }

.gc-board { list-style: none; margin: 0; padding: 6px; border-radius: 14px; background: var(--gc-board); border: 1px solid var(--gc-board-border); display: flex; flex-direction: column; gap: 3px; }
.gc-board[hidden] { display: none; }
.gc-board.is-shake .gc-row.is-active { animation: gc-shake .35s; }
.gc-row { display: grid; grid-template-columns: 22px 1fr auto; align-items: center; gap: 8px; padding: 3px 8px 3px 4px; border-radius: 10px; min-height: calc(var(--peg) + 8px); }
.gc-row .gc-pegs { justify-self: center; grid-column: 2; }
.gc-row .gc-fb { justify-self: end; }
.gc-num { color: var(--gc-muted); font-weight: 700; font-size: .78rem; text-align: right; font-variant-numeric: tabular-nums; opacity: .8; }
.gc-row.is-active { background: var(--gc-row-active); box-shadow: inset 0 0 0 2px var(--gc-accent); }
.gc-row.is-active .gc-num { color: var(--gc-accent); opacity: 1; }
.gc-row.is-thinking .gc-slot.is-empty { animation: gc-blink 1s infinite; }
.gc-row.is-last { background: color-mix(in srgb, var(--gc-accent) 7%, transparent); }

.gc-slot { width: var(--peg); height: var(--peg); border-radius: 50%; padding: 0; border: 0; display: grid; place-items: center; background: var(--gc-hole); box-shadow: inset 0 2px 4px rgba(0, 0, 0, .18); flex: none; }
.gc-slot.is-empty { background: var(--gc-hole); opacity: .75; }
button.gc-slot { cursor: pointer; touch-action: manipulation; }
.gc-slot.is-editable { background: var(--gc-card-bg); box-shadow: inset 0 0 0 2px var(--gc-hole-in); }
.gc-slot.is-sel { box-shadow: inset 0 0 0 2px var(--gc-hole-in), 0 0 0 3px var(--gc-accent); }
.gc-slot.is-drop { box-shadow: 0 0 0 4px var(--gc-accent); transform: scale(1.08); }
.gc-slot .gc-peg { width: 100%; height: 100%; }
.gc-slot.is-pop .gc-peg { animation: gc-pop .25s cubic-bezier(.2, 1.5, .4, 1); }

.gc-peg { width: var(--peg); height: var(--peg); border-radius: 50%; display: grid; place-items: center; flex: none; border: 0; padding: 0; background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, .45), rgba(255, 255, 255, 0) 45%), var(--pc); color: var(--pi); box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .2), 0 1px 2px rgba(0, 0, 0, .25); }
.gc-peg svg { width: 58%; height: 58%; pointer-events: none; }
.gc-peg.c0 { --pc: var(--gc-c0); --pi: var(--gc-i0); }
.gc-peg.c1 { --pc: var(--gc-c1); --pi: var(--gc-i1); }
.gc-peg.c2 { --pc: var(--gc-c2); --pi: var(--gc-i2); }
.gc-peg.c3 { --pc: var(--gc-c3); --pi: var(--gc-i3); }
.gc-peg.c4 { --pc: var(--gc-c4); --pi: var(--gc-i4); }
.gc-peg.c5 { --pc: var(--gc-c5); --pi: var(--gc-i5); }
.gc-peg.c6 { --pc: var(--gc-c6); --pi: var(--gc-i6); }
.gc-peg.c7 { --pc: var(--gc-c7); --pi: var(--gc-i7); }

.gc-fb { display: grid; grid-template-columns: repeat(2, 13px); gap: 4px; padding: 3px; }
.gc-fb.n5 { grid-template-columns: repeat(3, 12px); }
.gc-fbp { width: 13px; height: 13px; border-radius: 50%; background: var(--gc-hole); box-shadow: inset 0 1px 2px rgba(0, 0, 0, .25); }
.gc-fb.n5 .gc-fbp { width: 12px; height: 12px; }
.gc-fbp.is-black { background: var(--gc-fb-black); box-shadow: 0 0 0 1.5px var(--gc-fb-ring); }
.gc-fbp.is-white { background: var(--gc-fb-white); box-shadow: 0 0 0 1.5px var(--gc-fb-ring); }
.gc-row.is-last .gc-fbp.is-black, .gc-row.is-last .gc-fbp.is-white { animation: gc-pop .3s cubic-bezier(.2, 1.5, .4, 1) backwards; }
.gc-row.is-last .gc-fbp:nth-child(2) { animation-delay: .08s; }
.gc-row.is-last .gc-fbp:nth-child(3) { animation-delay: .16s; }
.gc-row.is-last .gc-fbp:nth-child(4) { animation-delay: .24s; }
.gc-row.is-last .gc-fbp:nth-child(5) { animation-delay: .32s; }

/* palette + buttons stick to the bottom of the screen while the board scrolls */
.gc-controls { position: sticky; bottom: 0; z-index: 3; margin: 10px -12px 0; padding: 10px 12px 12px; border-radius: 0 0 20px 20px; background: color-mix(in srgb, var(--gc-card-bg) 94%, transparent); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); border-top: 1px solid var(--gc-card-border); }
.gc-palette { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; justify-items: center; margin-bottom: 10px; touch-action: none; }
.gc-palette.n8 { grid-template-columns: repeat(8, 1fr); gap: 5px; }
.gc-pal { --peg: 46px; width: min(var(--peg), 100%); height: auto; aspect-ratio: 1; cursor: grab; touch-action: none; transition: transform .1s, opacity .15s; user-select: none; -webkit-user-select: none; }
.gc-palette.n8 .gc-pal { --peg: 42px; }
.gc-pal:active:not(:disabled) { transform: scale(.92); }
.gc-pal:disabled { opacity: .3; cursor: default; }
.gc-play.is-idle .gc-pal:disabled { opacity: .45; }
.gc-actions { display: grid; grid-template-columns: 1fr 1.6fr; gap: 8px; }
.gc-ghost { position: fixed; left: 0; top: 0; z-index: 2000; --peg: 50px; pointer-events: none; box-shadow: 0 8px 20px rgba(0, 0, 0, .35); }

.gc-btn { min-height: 48px; border-radius: 12px; border: 1px solid var(--gc-card-border); background: var(--gc-card-bg); color: inherit; font-weight: 700; font-size: .95rem; padding: 8px 14px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; touch-action: manipulation; line-height: 1.2; }
.gc-btn b { font-weight: 700; }
.gc-btn span { display: inline-flex; align-items: center; gap: 8px; }
.gc-btn:hover:not(:disabled) { border-color: var(--gc-accent); }
.gc-btn:disabled { opacity: .45; cursor: default; }
.gc-btn-primary { background: var(--gc-accent); border-color: var(--gc-accent); color: var(--gc-accent-ink); }
.gc-btn:focus-visible, .gc-seg:focus-visible, .gc-chip:focus-visible, .gc-toggle:focus-visible, .gc-link:focus-visible, .gc-pal:focus-visible, button.gc-slot:focus-visible { outline: 2px solid var(--gc-accent); outline-offset: 2px; }
.gc-under { display: flex; justify-content: center; margin: 12px 0 0; }
.gc-under .gc-btn { min-width: 180px; }

/* ---- overlays ---- */
.gc-overlay { position: absolute; inset: 0; z-index: 5; display: grid; place-items: start center; padding: 70px 10px 10px; border-radius: 20px; background: color-mix(in srgb, var(--gc-page-bg) 72%, transparent); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); animation: gc-fade .2s ease-out; }
.gc-overlay[hidden] { display: none !important; }
#gc-cover { background: var(--gc-page-bg); }
.gc-card { width: min(100%, 360px); padding: 18px 16px 16px; border-radius: 18px; background: var(--gc-card-bg); border: 1px solid var(--gc-card-border); box-shadow: 0 16px 40px rgba(0, 0, 0, .25); text-align: center; animation: gc-pop .3s cubic-bezier(.2, 1.4, .4, 1); }
.gc-card h2 { font-family: inherit; font-style: normal; font-size: 1.28rem; font-weight: 800; margin: 0 0 8px; overflow-wrap: anywhere; color: var(--text-color); text-transform: none; letter-spacing: normal; }
.gc-card p { color: var(--gc-muted); margin: 8px 0 14px; font-size: .95rem; }
.gc-card p:empty { display: none; }
.gc-card-icon { font-size: 1.8rem; color: var(--gc-accent); margin-bottom: 4px; }
.gc-card-icon span[hidden] { display: none; }
.gc-card-icon.is-win { color: #d97706; }
.gc-card-icon.is-lose { color: var(--gc-muted); }
.gc-card-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.gc-over-code { justify-content: center; --peg: 40px; padding: 8px; border-radius: 14px; background: var(--gc-board); width: max-content; margin: 0 auto; }

/* ---- settings ---- */
.gc-settings { margin: 14px 0 6px; padding: 14px; border-radius: 18px; background: var(--gc-card-bg); border: 1px solid var(--gc-card-border); }
.gc-settings-title { font-family: inherit; font-style: normal; font-size: 1.05rem; font-weight: 800; margin: 0 0 10px; text-transform: none; letter-spacing: normal; color: var(--text-color); display: flex; align-items: center; gap: 8px; }
.gc-opts { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin: 0 0 10px; }
.gc-opts[hidden], .gc-names[hidden] { display: none; }
.gc-opts-label { color: var(--gc-muted); font-weight: 700; font-size: .9rem; min-width: 8.2em; }
.gc-chips { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.gc-chip { min-height: 42px; min-width: 52px; padding: 6px 14px; border-radius: 999px; border: 1px solid var(--gc-card-border); background: var(--gc-page-bg); color: inherit; font-weight: 700; font-size: .92rem; cursor: pointer; touch-action: manipulation; }
.gc-chip[aria-checked="true"] { background: var(--gc-accent-soft); border-color: var(--gc-accent); color: var(--gc-accent); }
.gc-names { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 0 0 10px; }
.gc-name { margin: 0; }
.gc-name input { width: 100%; min-height: 44px; padding: 6px 12px; border-radius: 12px; border: 1px solid var(--gc-card-border); background: var(--gc-page-bg); color: inherit; font-size: 16px; font-weight: 600; outline: none; }
.gc-name input:focus { border-color: var(--gc-accent); }
.gc-toggle { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 6px 2px; border: 0; background: none; color: inherit; font-weight: 700; font-size: .92rem; text-align: left; cursor: pointer; line-height: 1.3; }
.gc-toggle small { display: block; font-weight: 500; color: var(--gc-muted); font-size: .8rem; }
.gc-switch { flex: none; position: relative; width: 46px; height: 28px; border-radius: 999px; background: var(--gc-hole); transition: background-color .2s; }
.gc-switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .2s; }
.gc-toggle[aria-checked="true"] .gc-switch { background: var(--gc-accent); }
.gc-toggle[aria-checked="true"] .gc-switch::after { transform: translateX(18px); }
.gc-apply-note { color: var(--gc-accent); font-weight: 600; font-size: .85rem; margin: 6px 0 0; }
.gc-apply-note:empty { display: none; }

.gc-tools { display: flex; justify-content: center; gap: 6px 18px; flex-wrap: wrap; margin: 6px 0 2px; }
.gc-link { border: 0; background: none; color: var(--gc-accent); font-weight: 600; font-size: .9rem; padding: 10px 4px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; min-height: 44px; }
.gc-link span { display: inline-flex; align-items: center; gap: 6px; }
.gc-link span[hidden] { display: none; }
.gc-stats { margin: 0 0 14px; color: var(--gc-muted); font-size: .86rem; text-align: center; }
.gc-stats p { margin: 6px 0 0; }
.gc-stats-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.gc-stats-table caption { caption-side: top; text-align: center; color: var(--gc-muted); font-weight: 700; padding: 0 0 4px; }
.gc-stats-table th, .gc-stats-table td { padding: 5px 4px; border-bottom: 1px solid var(--gc-card-border); text-align: center; color: var(--text-color); }
.gc-stats-table thead th { font-weight: 700; font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--gc-muted); }
.gc-stats-table tbody th { text-align: left; font-weight: 600; }

.gc-help { padding: 12px 16px; border-radius: 14px; background: var(--gc-card-bg); border: 1px solid var(--gc-card-border); }
.gc-help summary { font-weight: 700; cursor: pointer; min-height: 28px; }
.gc-help ul { margin: 10px 0 8px; padding-left: 20px; line-height: 1.55; }
.gc-help li { margin-bottom: 4px; }
.gc-help p { margin: 0; color: var(--gc-muted); font-size: .9rem; }
.gc-help kbd { font-size: .8em; padding: 1px 5px; }
.gc-credit { color: var(--gc-muted); font-size: .78rem; text-align: center; margin: 12px 0 0; line-height: 1.5; }
.gc-credit a, .gc-powered a { color: var(--gc-accent); }
.gc-powered { text-align: center; color: var(--gc-muted); font-size: .85rem; margin: 18px 0 0; }

@keyframes gc-pop { from { opacity: 0; transform: scale(.6); } }
@keyframes gc-fade { from { opacity: 0; } }
@keyframes gc-blink { 50% { opacity: .35; } }
@keyframes gc-shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

@media (min-width: 700px) {
    .gc-play { --peg: 42px; padding: 16px 18px 0; }
    .gc-play.is-five { --peg: 40px; }
    .gc-controls { margin: 12px -18px 0; padding: 12px 18px 16px; }
    .gc-pal { --peg: 52px; }
    .gc-palette.n8 .gc-pal { --peg: 48px; }
    .gc-fb { grid-template-columns: repeat(2, 15px); }
    .gc-fbp { width: 15px; height: 15px; }
}
@media (min-width: 992px) {
    .gc-wrap { max-width: 900px; }
    .gc-head, .gc-modes, .gc-duo { max-width: 560px; margin-left: auto; margin-right: auto; }
    .gc-play { display: grid; grid-template-columns: minmax(0, 1fr) 270px; column-gap: 24px; align-items: start; padding: 18px 22px 22px; --peg: 42px; }
    .gc-status, .gc-secret, .gc-board { grid-column: 1; }
    .gc-controls { grid-column: 2; grid-row: 1 / span 3; position: sticky; top: 96px; margin: 0; padding: 16px; border-radius: 16px; border: 1px solid var(--gc-board-border); background: var(--gc-board); }
    .gc-palette { grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
    .gc-palette.n8 { grid-template-columns: repeat(4, 1fr); gap: 10px; }
    .gc-pal { --peg: 60px; }
    .gc-palette.n8 .gc-pal { --peg: 52px; }
    .gc-actions { grid-template-columns: 1fr; }
    .gc-actions #gc-check { order: -1; min-height: 52px; }
    .gc-overlay { padding-top: 110px; }
}
@media (max-width: 420px) {
    .gc-main { padding-top: 84px; }
    .gc-head h1 { font-size: 1.7rem; }
    .gc-lead { font-size: .9rem; }
    .gc-seg { flex-direction: column; gap: 3px; font-size: .8rem; padding: 6px 2px; min-height: 54px; }
    .gc-play { padding: 10px 8px 0; --peg: 34px; }
    .gc-play.is-five { --peg: 31px; }
    .gc-controls { margin: 10px -8px 0; padding: 10px 8px 10px; }
    .gc-row { gap: 6px; padding: 2px 6px 2px 2px; grid-template-columns: 18px 1fr auto; }
    .gc-board { padding: 4px; }
    .gc-settings { padding: 12px 10px; }
    .gc-opts-label { min-width: 7.6em; font-size: .86rem; }
}

@media (prefers-reduced-motion: reduce) {
    .gc-slot.is-pop .gc-peg, .gc-row.is-last .gc-fbp, .gc-card, .gc-overlay, .gc-board.is-shake .gc-row.is-active, .gc-row.is-thinking .gc-slot.is-empty { animation: none; }
}
