/* Shared styles for the newer games (tetris ... simon). */
.hint { color: var(--text-muted); font-size: .82rem; text-align: center; font-weight: 600; margin: 0; max-width: 460px; }
.stage { width: 100%; display: flex; flex-direction: column; align-items: center; gap: .8rem; }

.cv-wrap {
  --w: 420px; --arn: .75;
  width: min(100%, var(--w), calc((100vh - 250px) * var(--arn)));
  min-width: 230px;
  aspect-ratio: var(--ar, 3 / 4);
  border: 3px solid var(--accent);
  border-radius: 16px;
  overflow: hidden;
  background: var(--board-bg);
  box-shadow: var(--glow), inset 0 0 30px rgba(0,0,0,.5);
  touch-action: none;
  position: relative;
  user-select: none; -webkit-user-select: none;
}
.cv-wrap canvas { width: 100%; height: 100%; display: block; touch-action: none; }

.ctrl-row { display: flex; gap: .5rem; width: 100%; max-width: 420px; }
.ctrl-row .btn { flex: 1; padding: .85rem 0; font-size: 1.25rem; touch-action: manipulation; user-select: none; -webkit-user-select: none; }

.info-bar { display: flex; gap: .6rem; flex-wrap: wrap; justify-content: center; font-weight: 800; font-size: .85rem; color: var(--text-muted); }
.info-bar b { color: var(--text-main); font-variant-numeric: tabular-nums; }

.seg { display: inline-flex; border: 1px solid rgba(255,255,255,.2); border-radius: 999px; overflow: hidden; }
.seg button { background: var(--bg-panel); color: var(--text-muted); border: 0; padding: .45rem .9rem; font-weight: 800; font-size: .8rem; touch-action: manipulation; }
.seg button.on { background: var(--accent); color: #1a1027; }

/* --- square-grid boards (lights out, memory, whack-a-mole, tic tac toe, connect 4) --- */
.sq-board { display: grid; gap: 8px; width: min(100%, 420px, calc(100vh - 300px)); min-width: 240px; padding: 10px; background: var(--board-bg); border: 3px solid var(--accent); border-radius: 16px; box-shadow: var(--glow); user-select: none; -webkit-user-select: none; }
.sq-board button, .sq-board .cell {
  aspect-ratio: 1; border: 0; border-radius: 12px; background: var(--cell-bg); color: var(--text-main);
  font-size: clamp(1.4rem, 8vw, 2.6rem); display: flex; align-items: center; justify-content: center;
  touch-action: manipulation; padding: 0; transition: transform .12s, background .15s;
}
.sq-board button:active { transform: scale(.94); }

/* lights out */
.lo-board { grid-template-columns: repeat(5, 1fr); }
.lo-board button { background: rgba(255,255,255,.07); box-shadow: inset 0 0 0 2px rgba(255,255,255,.08); }
.lo-board button.on { background: var(--accent); box-shadow: 0 0 18px var(--accent), inset 0 0 0 3px rgba(255,255,255,.4); }

/* memory */
.mem-board button { position: relative; perspective: 600px; background: transparent; }
.mem-board .face { position: absolute; inset: 0; border-radius: 12px; display: flex; align-items: center; justify-content: center; backface-visibility: hidden; transition: transform .35s; }
.mem-board .front { background: var(--card-face); transform: rotateY(180deg); }
.mem-board .back { background: linear-gradient(135deg, var(--card-back), var(--accent-2)); font-size: .5em; color: rgba(255,255,255,.55); }
.mem-board button.up .front { transform: rotateY(0); }
.mem-board button.up .back { transform: rotateY(180deg); }
.mem-board button.done .front { background: var(--accent-3); }
.mem-board button.done { opacity: .75; }

/* whack-a-mole */
.mole-board { grid-template-columns: repeat(3, 1fr); gap: 10px; }
.hole { position: relative; aspect-ratio: 1; border-radius: 50%; background: radial-gradient(circle closest-side at 50% 50%, #000 0 78%, rgba(255,255,255,.07) 80%); overflow: hidden; touch-action: manipulation; }
.hole .mole { position: absolute; left: 0; right: 0; bottom: -100%; text-align: center; font-size: clamp(2rem, 13vw, 4rem); transition: bottom .12s; line-height: 1; padding-bottom: 6%; pointer-events: none; }
.hole.up .mole { bottom: 4%; }
.hole.hit { background: radial-gradient(circle closest-side at 50% 50%, #000 0 78%, var(--accent-3) 80%); }
.hole.bad { background: radial-gradient(circle closest-side at 50% 50%, #000 0 78%, #ff3d5c 80%); }

/* tic tac toe */
.ttt-board { grid-template-columns: repeat(3, 1fr); }
.ttt-board button { font-family: var(--font-display); font-size: clamp(2.4rem, 16vw, 4.4rem); }
.ttt-board button.win { background: var(--accent); color: #1a1027; }
.ttt-board button.x { color: var(--accent-3); }
.ttt-board button.o { color: var(--accent); }

/* connect four */
.c4-board { grid-template-columns: repeat(7, 1fr); gap: 5px; padding: 8px; background: var(--accent-2); }
.c4-board .cell { aspect-ratio: 1; border-radius: 50%; background: var(--board-bg); padding: 0; position: relative; box-shadow: inset 0 3px 8px rgba(0,0,0,.6); }
.c4-board .cell.p1::after, .c4-board .cell.p2::after { content: ''; position: absolute; inset: 7%; border-radius: 50%; animation: drop .35s cubic-bezier(.3,1.3,.5,1); }
.c4-board .cell.p1::after { background: var(--accent); box-shadow: inset 0 -4px 8px rgba(0,0,0,.35); }
.c4-board .cell.p2::after { background: var(--accent-3); box-shadow: inset 0 -4px 8px rgba(0,0,0,.35); }
.c4-board .cell.win::after { outline: 4px solid #fff; }
.c4-board .cell { cursor: pointer; }
@keyframes drop { from { transform: translateY(-300%); } to { transform: none; } }

/* simon */
.simon { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: min(100%, 360px, calc(100vh - 300px)); min-width: 240px; padding: 10px; background: var(--board-bg); border: 3px solid var(--accent); border-radius: 50%; box-shadow: var(--glow); aspect-ratio: 1; }
.simon button { border: 0; border-radius: 12px; opacity: .45; touch-action: manipulation; transition: opacity .08s, transform .08s; }
.simon button:nth-child(1) { border-top-left-radius: 100%; }
.simon button:nth-child(2) { border-top-right-radius: 100%; }
.simon button:nth-child(3) { border-bottom-left-radius: 100%; }
.simon button:nth-child(4) { border-bottom-right-radius: 100%; }
.simon button.lit { opacity: 1; transform: scale(1.03); box-shadow: 0 0 30px currentColor; }
.simon button:active { opacity: 1; }

/* ---------------- playing cards (freecell / hearts / spades) ---------------- */
.cards-area { --cw: 44px; --ch: calc(var(--cw) * 1.42); width: 100%; position: relative; user-select: none; -webkit-user-select: none; }
.pc {
  position: absolute; width: var(--cw); height: var(--ch);
  background: var(--card-face); color: var(--card-black); border-radius: calc(var(--cw) * .12);
  border: 1px solid rgba(0,0,0,.35); box-shadow: 0 2px 4px rgba(0,0,0,.45);
  font-weight: 800; touch-action: manipulation; overflow: hidden; box-sizing: border-box;
  transition: top .15s, left .15s, transform .12s;
}
.pc.red { color: var(--card-red); }
.pc .tl { position: absolute; top: 2%; left: 7%; line-height: 1; font-size: calc(var(--cw) * .34); text-align: center; }
.pc .tl i { display: block; font-style: normal; font-size: .9em; margin-top: -1px; }
.pc .mid { position: absolute; right: 8%; bottom: 3%; font-size: calc(var(--cw) * .56); line-height: 1; }
.pc.down { background: repeating-linear-gradient(45deg, var(--card-back), var(--card-back) 6px, var(--accent-2) 6px, var(--accent-2) 12px); }
.pc.down .tl, .pc.down .mid { display: none; }
.pc.sel { transform: translateY(-8px); box-shadow: 0 0 0 3px var(--accent-3), 0 6px 10px rgba(0,0,0,.5); z-index: 500 !important; }
.pc.hint { box-shadow: 0 0 0 3px var(--accent); }
.pc.dim { filter: brightness(.55); }
.slot { position: absolute; width: var(--cw); height: var(--ch); border: 2px dashed rgba(255,255,255,.2); border-radius: calc(var(--cw) * .12); box-sizing: border-box; display: flex; align-items: center; justify-content: center; color: rgba(255,255,255,.25); font-size: calc(var(--cw) * .5); touch-action: manipulation; }
.slot.hot { border-color: var(--accent-3); }

.table-msg { text-align: center; font-weight: 800; color: var(--accent-3); min-height: 1.4em; }
.score-table { width: 100%; max-width: 420px; border-collapse: collapse; font-size: .85rem; }
.score-table th, .score-table td { padding: .3rem .4rem; text-align: center; border-bottom: 1px solid rgba(255,255,255,.1); }
.score-table th { color: var(--text-muted); font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; }
.score-table td.you { color: var(--accent-3); font-weight: 800; }
.bid-row { display: flex; flex-wrap: wrap; gap: .4rem; justify-content: center; max-width: 380px; }
.bid-row .btn { padding: .55rem .8rem; min-width: 46px; }

/* seat labels at 4-player tables */
.seat-tag { position: absolute; z-index: 600; background: var(--bg-panel); border: 1px solid rgba(255,255,255,.15); border-radius: 999px; padding: .15rem .6rem; font-size: .7rem; font-weight: 800; color: var(--text-main); white-space: nowrap; max-width: 46%; overflow: hidden; text-overflow: ellipsis; }
.cards-area[id="area"] { min-height: 300px; }
.mole-board .hole { align-self: start; width: 100%; }
.mole-board .hole { aspect-ratio: auto; height: 0; padding-bottom: 100%; }
