:root {
  color-scheme: dark;
  font-family: "Courier New", monospace;
  background: #000;
  color: #fff;
}

* { box-sizing: border-box; }
body { margin: 0; background: #000; color: #fff; }
body::after { content: ""; position: fixed; inset: 0; background: repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(255,255,255,0.025) 2px, rgba(255,255,255,0.025) 4px); pointer-events: none; z-index: 10; }
button { cursor: pointer; border: 1px solid rgba(255,255,255,.55); border-radius: 0; padding: 0.56rem 0.7rem; font: inherit; font-size: 0.82rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; background: #000; color: #fff; }
button:hover:not(:disabled) { background: rgba(255,255,255,.1); border-color: #fff; box-shadow: 0 0 8px rgba(255,255,255,.35), inset 0 0 8px rgba(255,255,255,.1); }
button:disabled { opacity: 0.35; cursor: not-allowed; }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { font-weight: 400; text-transform: uppercase; letter-spacing: 0.18em; }
h1 { margin-bottom: 0.35rem; font-size: 1.35rem; }
h2 { font-size: 0.9rem; color: rgba(255,255,255,.82); }
h3 { font-size: 0.82rem; }
.table { max-width: 1180px; margin: 0 auto; padding: 18px; }
.top-bar, .hand-heading, .actions, .header-actions, .top-grid { display: flex; gap: 14px; align-items: center; }
.top-bar { justify-content: space-between; margin-bottom: 16px; border: 1px solid rgba(255,255,255,.28); padding: 14px; background: rgba(255,255,255,.025); box-shadow: 0 0 18px rgba(255,255,255,.06); }
.game-status, .turn-status { color: #fff; font-weight: 700; }
.muted-line { color: rgba(255,255,255,.62); }
.panel { background: rgba(255,255,255,.035); border: 1px solid rgba(255,255,255,.35); border-radius: 0; padding: 14px; margin-bottom: 14px; box-shadow: 0 0 18px rgba(255,255,255,.06), inset 0 0 18px rgba(255,255,255,.025); }
.betting { border-color: rgba(255,255,255,.75); }
.top-grid { align-items: stretch; }
.top-grid > .panel, .top-grid > .trick-stack { flex: 1; min-width: 0; }
.trick-stack { flex: 1.35; display: flex; flex-direction: column; gap: 8px; }
.trick-panel { flex: 1; }
.score-panel { flex: 1; }
.log-panel { flex: 1; }
.hand-heading { justify-content: space-between; align-items: center; }
.sort-actions { justify-content: flex-start; }
.play-actions { justify-content: flex-end; }
.hand-actions { flex-wrap: nowrap; white-space: nowrap; }
.hand-actions button { padding: 0.48rem 0.58rem; font-size: 0.74rem; }
.hand { display: flex; flex-wrap: wrap; gap: 10px; padding-top: 8px; }
.card, .mini-card, .tiny-card { border-radius: 0; background: #000; color: #fff; border: 1px solid rgba(255,255,255,.72); box-shadow: 0 0 10px rgba(255,255,255,.12), inset 0 0 10px rgba(255,255,255,.04); display: grid; place-items: center; position: relative; font-family: "Courier New", monospace; overflow: hidden; }
.card::before, .mini-card::before, .tiny-card::before { content: ""; position: absolute; inset: 8px; background: var(--card-color); border: 1px solid #fff; opacity: 0.9; z-index: 0; }
.card:not(.wild-card)::before, .mini-card:not(.wild-card)::before, .tiny-card:not(.wild-card)::before { box-shadow: 0 0 14px var(--card-color); }
.wild-card::before { box-shadow: 0 0 18px rgba(0,213,255,.45), 0 0 24px rgba(123,63,105,.35); }
.rank, .stars, .wild { position: relative; z-index: 1; text-shadow: 0 1px 2px #000, 0 0 6px #000; }
.card { width: 76px; height: 106px; font-weight: 700; }
.card .rank { font-size: 2.35rem; line-height: 1; }
.card.selected { transform: translateY(-12px); border-color: #fff; background: #fff; color: #fff; box-shadow: 0 0 16px rgba(255,255,255,.45); }
.card.selected::before { box-shadow: none; opacity: 1; }
.card.dragging { opacity: 0.55; transform: translateY(-8px); }
.card.drop-before::after,
.card.drop-after::after { content: ""; position: absolute; top: -10px; bottom: -10px; width: 3px; border-radius: 0; background: #fff; box-shadow: 0 0 0 3px rgba(255,255,255,0.16), 0 0 16px rgba(255,255,255,0.75); pointer-events: none; }
.card.drop-before::after { left: -9px; }
.card.drop-after::after { right: -9px; }
.stars { position: absolute; right: 14px; bottom: 12px; font-size: 0.82rem; letter-spacing: -0.08em; color: currentColor; opacity: 0.95; }
.wild { position: absolute; left: 16px; bottom: 12px; color: currentColor; font-size: 0.78rem; opacity: 0.95; text-transform: uppercase; }
.suit-c { --card-color: #7b3f69; }
.suit-d { --card-color: #00d5ff; }
.suit-h { --card-color: #0a7f3f; }
.suit-s { --card-color: #c99a16; }
.wild-card { --card-color: linear-gradient(135deg, #7b3f69 0%, #00d5ff 32%, #c99a16 66%, #0a7f3f 100%); }
.cpu-hand, .mini-hand, .trick-cards { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.cpu-hand { margin-bottom: 16px; }
.mini-hand { min-height: 52px; margin-bottom: 10px; }
.cpu-strip { min-height: 0; margin-bottom: 0; padding: 8px 10px; display: flex; align-items: center; gap: 8px; flex-wrap: nowrap; white-space: nowrap; }
.cpu-strip .tiny-card { margin-left: 2px; }
.trick-cards { min-height: 118px; align-content: center; }
.card-back { width: 24px; height: 36px; border-radius: 0; background: #000; border: 1px solid rgba(255,255,255,.55); box-shadow: inset 0 0 0 4px #000, inset 0 0 0 5px rgba(255,255,255,.35); }
.mini-card { width: 52px; height: 72px; }
.mini-card .rank { font-size: 1.55rem; }
.trick-cards .mini-card { width: 68px; height: 94px; }
.trick-cards .mini-card .rank { font-size: 2.1rem; }
.tiny-card { display: inline-grid; vertical-align: middle; width: 34px; height: 44px; margin-left: 4px; }
.tiny-card::before { inset: 5px; }
.tiny-card .rank { font-size: 1rem; }
.tiny-card .stars { display: none; }
.tiny-card .wild { font-size: 0.55rem; left: 6px; bottom: 2px; }
.mini-card .stars { right: 4px; bottom: 3px; font-size: 0.62rem; }
.mini-card .wild { left: 8px; bottom: 3px; font-size: 0.62rem; }
.section-label { width: 100%; margin: 0 0 2px; color: rgba(255,255,255,.7); font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.16em; }
.section-label.muted { color: rgba(255,255,255,.45); text-transform: none; letter-spacing: 0; font-weight: 400; }
.detail-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; padding-top: 12px; }
.log-panel ol { max-height: 180px; overflow: auto; }
.score-breakdown { margin: 12px 0; overflow-x: auto; }
.score-breakdown table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
.score-breakdown th, .score-breakdown td { padding: 6px 4px; border-bottom: 1px solid rgba(255,255,255,0.18); text-align: right; }
.score-breakdown th:first-child, .score-breakdown td:first-child { text-align: left; }
.score-breakdown tfoot th { color: #fff; border-top: 1px solid rgba(255,255,255,.55); }
.error { color: #fff; text-decoration: underline; }
summary { cursor: pointer; font-weight: 700; text-transform: uppercase; letter-spacing: 0.12em; }
#legal-moves { columns: 1; }
.visually-hidden { display: none; }
@media (max-width: 980px) {
  .top-grid { display: block; }
}
@media (max-width: 820px) {
  .top-bar, .hand-heading { display: block; }
  .detail-columns { grid-template-columns: 1fr; }
  .actions, .header-actions, .hand-actions { display: flex; flex-wrap: wrap; margin-top: 10px; }
}
