@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@300;400;500&family=Syne:wght@400;700;800&display=swap');

:root {
  --bg: #0e0e0e;
  --surface: #161616;
  --surface2: #1d1d1d;
  --border: #2a2a2a;
  --text: #e8e8e8;
  --muted: #666;
  --accent: #c8f060;
  --red: #ff4d4d;
  --blue: #4d9fff;
  --felt: #143d26;
  --accent-dim: rgba(200,240,96,.14);
  --shadow: 0 18px 50px rgba(0,0,0,.35);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }
body {
  background:
    radial-gradient(circle at 15% -10%, rgba(200,240,96,.075), transparent 32rem),
    radial-gradient(circle at 90% 105%, rgba(77,159,255,.05), transparent 28rem),
    var(--bg);
  color: var(--text);
  font-family: 'DM Mono', monospace;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

header.gbar {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0; background: rgba(14,14,14,.84); backdrop-filter: blur(12px);
  position: relative; z-index: 10;
}
header.gbar h1 { font-family: 'Syne', sans-serif; font-weight: 800; font-size: 1rem; letter-spacing: -0.5px; }
header.gbar h1 span { color: var(--accent); }
header.gbar a.back { color: var(--muted); text-decoration: none; font-size: .8rem; transition: color .18s, transform .18s; }
header.gbar a.back:hover { color: var(--accent); }
header.gbar a.back:active { transform: translateX(-2px); }
header.gbar .spacer { flex: 1; }
header.gbar .stat { font-size: .72rem; color: var(--muted); }
header.gbar .stat b { color: var(--accent); font-weight: 500; }

button.gbtn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: inherit;
  font-size: .72rem;
  padding: 7px 12px;
  border-radius: 6px;
  cursor: pointer;
  letter-spacing: .4px;
  touch-action: manipulation; transition: transform .12s, border-color .18s, color .18s, background .18s, box-shadow .18s;
}
button.gbtn:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-1px); }
button.gbtn:active { transform: translateY(1px) scale(.98); }
button.gbtn.primary { background: var(--accent); color: #0e0e0e; border-color: var(--accent); font-weight: 500; box-shadow: 0 5px 18px rgba(200,240,96,.12); }
button.gbtn.primary:hover { color: #0e0e0e; box-shadow: 0 7px 24px rgba(200,240,96,.24); }
button.gbtn:disabled { opacity: .35; cursor: default; }
button.gbtn:focus-visible, select.gsel:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
select.gsel {
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  font-family: inherit; font-size: .72rem; padding: 6px 8px; border-radius: 6px;
}

main.gmain {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px;
  gap: 10px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; align-items: center; }
.msg { font-size: .8rem; color: var(--muted); min-height: 1.2em; text-align: center; }
.msg.win { color: var(--accent); }
.msg.lose { color: var(--red); }

/* ---------- playing cards ---------- */
.card {
  width: var(--cw, 64px);
  height: calc(var(--cw, 64px) * 1.45);
  border-radius: 6px;
  background: #f4f1e8;
  border: 1px solid #999;
  position: relative;
  user-select: none;
  cursor: pointer;
  font-family: 'DM Mono', monospace;
  box-shadow: 0 3px 9px rgba(0,0,0,.45);
  flex-shrink: 0;
}
.card.red { color: #c62828; }
.card.black { color: #1a1a1a; }
.card .tl, .card .br {
  position: absolute;
  font-size: calc(var(--cw, 64px) * .26);
  line-height: 1.05;
  font-weight: 500;
  text-align: center;
}
.card .tl { top: 3px; left: 4px; }
.card .br { bottom: 3px; right: 4px; transform: rotate(180deg); }
.card .pip {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: calc(var(--cw, 64px) * .55);
}
.card.back {
  background: repeating-linear-gradient(45deg, #22301f 0 6px, #2c3f28 6px 12px);
  border-color: #444;
}
.card.back .tl, .card.back .br, .card.back .pip { display: none; }
.card.sel { outline: 2px solid var(--accent); outline-offset: -1px; }
.card.sel { transform: translateY(-5px); box-shadow: 0 8px 20px rgba(0,0,0,.5), 0 0 18px rgba(200,240,96,.18); }
.card.hint { outline: 2px dashed var(--blue); outline-offset: -1px; }

.slot {
  width: var(--cw, 64px);
  height: calc(var(--cw, 64px) * 1.45);
  border-radius: 6px;
  border: 1px dashed #3a3a3a;
  background: rgba(255,255,255,.02);
  flex-shrink: 0;
  position: relative;
  color: #3a3a3a;
  display: flex; align-items: center; justify-content: center;
  font-size: calc(var(--cw, 64px) * .4);
  user-select: none;
}
.slot.sel { border-color: var(--accent); }

.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.78); backdrop-filter: blur(5px);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.overlay .panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 24px 28px; text-align: center; display: flex; flex-direction: column; gap: 14px;
  max-width: 90vw; box-shadow: var(--shadow); animation: panel-in .2s ease-out;
}
.overlay .panel h2 { font-family: 'Syne', sans-serif; color: var(--accent); }

@keyframes panel-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@media (max-width: 560px) {
  button.gbtn { min-height: 40px; padding: 8px 13px; }
  select.gsel { min-height: 40px; }
  header.gbar { padding-top: max(10px, env(safe-area-inset-top)); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
