* { box-sizing: border-box; }
:root{
  --gap: .9rem;
  --panel-bg: #11151c;
  --panel-border: #2a3140;
  --txt: #f6f7fb;
  --muted: #7e8aa7;
  --accent: #8fb1ff;
  --card-w: clamp(58px, 16vw, 120px);
  --card-h: clamp(82px, 23vw, 170px);
  --radius: 10px;
}
html, body { height: 100%; }
body { margin: 0; font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif; background: #0d0f14; color: var(--txt); }
a { color: var(--accent); text-decoration: none; }
button { cursor: pointer; border-radius: 10px; border: 1px solid var(--panel-border); background: #1b2130; color: var(--txt); padding: .65rem .9rem; font-weight: 600; touch-action: manipulation; }
button:active { transform: translateY(1px); }
button:hover { filter: brightness(1.05); }

.topbar { position: sticky; top: 0; z-index: 10; display: grid; grid-template-columns: 1fr auto; gap: .75rem; align-items: center; padding: .8rem; background: #151a22; border-bottom: 1px solid var(--panel-border); }
.topbar h1 { margin: 0; font-size: clamp(1rem, 2.5vw, 1.2rem); }
.controls { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.controls input { width: min(60vw, 220px); padding: .55rem .7rem; border-radius: 10px; border: 1px solid var(--panel-border); background: #0f1320; color: var(--txt); font-size: 1rem; }
.stats { display: flex; gap: .75rem; font-variant-numeric: tabular-nums; flex-wrap: wrap; }
.stats > div { background: #0f1320; border: 1px solid var(--panel-border); border-radius: 999px; padding: .35rem .6rem; }

.game { display: grid; grid-template-columns: 220px 1fr 340px; gap: var(--gap); padding: var(--gap); max-width: 1200px; margin: 0 auto; }
.left, .right { background: var(--panel-bg); border: 1px solid var(--panel-border); border-radius: var(--radius); padding: 1rem; }

.stock, .waste { width: var(--card-w); height: var(--card-h); border-radius: 12px; border: 2px dashed #3a4255; display: flex; align-items: center; justify-content: center; font-size: clamp(1.4rem, 5vw, 2rem); background: #0f1320; margin-bottom: .75rem; user-select: none; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.waste { background: #141a2b; }
.redeal { width: 100%; max-width: var(--card-w); }
.hint { margin-top: .5rem; min-height: 1.5rem; color: #9cb3ff; font-size: .95rem; }

.pyramid { background: #0e121a; border: 1px solid var(--panel-border); border-radius: var(--radius); padding: .7rem; display: grid; gap: .25rem; justify-items: center; }
.pyramid-row { display: flex; justify-content: center; gap: .25rem; width: 100%; }

.card { width: var(--card-w); height: var(--card-h); border-radius: 12px; background: #fdfdfd; color: #111; border: 1px solid #cfcfcf; display: flex; align-items: center; justify-content: center; font-size: clamp(1.1rem, 5vw, 1.7rem); font-weight: 700; position: relative; user-select: none; cursor: pointer; transition: transform .08s ease, box-shadow .08s ease; box-shadow: 0 2px 0 rgba(0,0,0,.25); -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.card.hidden { visibility: hidden; }
.card.blocked { filter: grayscale(0.7) opacity(.7); }
.card.selected { outline: 3px solid #3c8cff; transform: translateY(-2px); }
.card.k { background: #fff7f0; }
.card .small { position: absolute; top: 6px; left: 8px; font-size: .9rem; font-weight: 600; }

.right h2 { margin-top: 0; font-size: 1.05rem; }
.hs-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.hs { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; min-width: 420px; }
.hs th, .hs td { border-bottom: 1px solid var(--panel-border); padding: .5rem .4rem; }
.hs tbody tr:nth-child(odd){ background: #121824; }

.modal { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; background: rgba(0,0,0,.6); padding: 1rem; }
.modal.show { display: flex; }
.modal-content { background: var(--panel-bg); border: 1px solid var(--panel-border); border-radius: 12px; padding: 1rem 1.2rem; width: min(92vw, 420px); }
.modal-content h3 { margin: .2rem 0 .4rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: .5rem; }
.foot { text-align: center; padding: 1rem; color: var(--muted); }

@media (max-width: 1100px){ .game { grid-template-columns: 200px 1fr; } .right { grid-column: 1 / -1; } }
@media (max-width: 860px){ .game { grid-template-columns: 1fr; } .left { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; align-items: start; } .stock, .waste, .redeal { justify-self: center; } }
@media (max-width: 520px){ :root{ --gap: .7rem; --card-w: clamp(54px, 22vw, 96px); --card-h: clamp(76px, 32vw, 140px); } .controls input { width: min(70vw, 260px); } .topbar { grid-template-columns: 1fr; gap: .6rem; } .pyramid { padding: .5rem; gap: .2rem; } .pyramid-row { gap: .2rem; } .stats > div { padding: .32rem .55rem; } }
