html {
  color-scheme: light;
  background: #f4f5f6;
}
:root,
html[data-theme="light"] {
  --bg:#f4f5f6;
  --panel:#ffffff;
  --soft:#f0f2f3;
  --text:#24282b;
  --muted:#687078;
  --border:#d7dcdf;
  --primary:#30353a;
  --primary-text:#ffffff;
  --accent:#30353a;
}
html[data-theme="blue"] {
  --bg:#f1f5f8;
  --panel:#ffffff;
  --soft:#eaf1f6;
  --text:#24282b;
  --muted:#687078;
  --border:#d2dce5;
  --primary:#456f91;
  --primary-text:#ffffff;
  --accent:#456f91;
}
html[data-theme="green"] {
  --bg:#f2f5f2;
  --panel:#ffffff;
  --soft:#eaf1eb;
  --text:#24282b;
  --muted:#687078;
  --border:#d3ddd5;
  --primary:#52725a;
  --primary-text:#ffffff;
  --accent:#52725a;
}
html[data-theme="dark"] {
  color-scheme: dark;
  --bg:#181b1d;
  --panel:#23272a;
  --soft:#2c3134;
  --text:#f1f2f3;
  --muted:#adb3b7;
  --border:#3b4145;
  --primary:#e1e4e6;
  --primary-text:#202326;
  --accent:#e1e4e6;
}
* { box-sizing:border-box; }
html,body {
  margin:0;
  min-height:100%;
  font-family:Arial,Helvetica,sans-serif;
}
body {
  min-height:100vh;
  background:#f4f5f6;
  background:var(--bg);
  color:#24282b;
  color:var(--text);
}
.app {
  min-height:100vh;
  display:flex;
  flex-direction:column;
  background:var(--bg);
}
.topbar,.toolbar {
  background:var(--panel);
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:18px;
  padding:16px 22px;
}
.topbar { border-bottom:1px solid var(--border); }
.toolbar {
  border-top:1px solid var(--border);
  position:sticky;
  bottom:0;
  z-index:5;
}
h1 { margin:0; font-size:26px; }
.brand p {
  margin:5px 0 0;
  color:var(--muted);
  font-size:13px;
}
.header-right,.actions {
  display:flex;
  align-items:center;
  gap:8px;
}
.score {
  display:flex;
  gap:12px;
  align-items:center;
  min-width:118px;
  justify-content:space-between;
  background:var(--soft);
  border:1px solid var(--border);
  padding:9px 12px;
  border-radius:7px;
}
.score b { font-size:18px; }
button {
  font:inherit;
  font-weight:600;
  border:1px solid var(--border);
  border-radius:7px;
  background:var(--soft);
  color:var(--text);
  padding:10px 14px;
  cursor:pointer;
}
button.primary {
  background:var(--primary);
  border-color:var(--primary);
  color:var(--primary-text);
}
.board {
  flex:1;
  width:min(1050px,100%);
  margin:0 auto;
  padding:22px;
  display:grid;
  grid-template-rows:auto minmax(80px,1fr) auto;
  gap:18px;
}
.player-panel {
  background:var(--panel);
  border:1px solid var(--border);
  border-radius:10px;
  padding:16px 18px;
  box-shadow:0 2px 6px rgba(0,0,0,.05);
}
.player-panel h2 { font-size:16px; margin:0 0 15px; }
.hand {
  display:flex;
  justify-content:center;
  align-items:center;
  gap:13px;
  flex-wrap:wrap;
  min-height:150px;
}
.card {
  width:104px;
  height:148px;
  background:#fff;
  color:#17191b;
  border:1px solid #c8cdd0;
  border-radius:8px;
  box-shadow:0 3px 8px rgba(0,0,0,.13);
  position:relative;
  user-select:none;
  transition:transform .12s,border-color .12s,box-shadow .12s;
}
.card.play { cursor:pointer; }
.card.red { color:#bd2d2d; }
.card.locked {
  transform:translateY(-9px);
  border:3px solid var(--accent);
  box-shadow:0 5px 11px rgba(0,0,0,.18);
}
.card.locked::after {
  content:"LÅST";
  position:absolute;
  bottom:-23px;
  left:50%;
  transform:translateX(-50%);
  font-size:10px;
  font-weight:bold;
  color:var(--accent);
}
.corner {
  position:absolute;
  top:7px;
  left:8px;
  font-size:20px;
  font-weight:bold;
  line-height:19px;
}
.corner.bottom-card {
  top:auto;
  left:auto;
  right:8px;
  bottom:7px;
  transform:rotate(180deg);
}
.suit {
  position:absolute;
  inset:0;
  display:grid;
  place-items:center;
  font-size:54px;
}
.back { padding:7px; }
.back::after {
  content:"";
  display:block;
  width:100%;
  height:100%;
  border-radius:5px;
  border:1px solid #bbb;
  background:repeating-linear-gradient(45deg,#555 0 5px,#eee 5px 10px);
}
.phase-panel {
  display:grid;
  place-items:center;
  color:var(--muted);
}
.phase-panel b { color:var(--text); }
.hand-name {
  text-align:center;
  font-weight:bold;
  margin-top:18px;
  min-height:20px;
}
.hint,#lockInfo {
  font-size:13px;
  color:var(--muted);
}
#lockInfo { margin-top:4px; }
dialog {
  width:min(470px,calc(100% - 30px));
  padding:0;
  border:1px solid var(--border);
  border-radius:10px;
  background:var(--panel);
  color:var(--text);
  box-shadow:0 18px 50px rgba(0,0,0,.25);
}
dialog::backdrop { background:rgba(0,0,0,.45); }
.dialog-head {
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:15px 18px;
  border-bottom:1px solid var(--border);
}
.dialog-head h2 { margin:0; font-size:19px; }
.close {
  border:0;
  background:transparent;
  font-size:24px;
  padding:0;
}
.dialog-body { padding:15px 18px; }
table { width:100%; border-collapse:collapse; }
td { padding:8px; border-bottom:1px solid var(--border); }
td:last-child { text-align:right; font-weight:bold; }
.theme-grid {
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:8px;
}
@media(max-width:700px) {
  .topbar { align-items:flex-start; flex-direction:column; }
  .header-right { width:100%; flex-wrap:wrap; }
  .board { padding:12px; }
  .card { width:69px; height:100px; }
  .suit { font-size:37px; }
  .corner { font-size:14px; line-height:14px; }
  .hand { gap:7px; }
  .toolbar { align-items:stretch; flex-direction:column; }
  .actions { justify-content:flex-end; }
}