:root {
  --bg: #1f5a3a;
  --felt: #246b45;
  --panel: rgba(0, 0, 0, 0.18);
  --text: #fff;
  --muted: #cfe6d8;
  --blue: #1f5fbf;
  --green: #2b8a3e;
  --red: #c92a2a;
  --sb: #e8590c;
  --card-w: 64px;
  --card-h: 90px;
  --glow: #ffe066;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: radial-gradient(circle at 50% 30%, var(--felt), var(--bg));
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 18px;
  min-height: 100vh;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
}

h1 { margin: 0; font-size: 24px; letter-spacing: 1px; }
h2 { font-size: 18px; margin: 0 0 6px; font-weight: 600; color: var(--muted); }

main { max-width: 960px; margin: 0 auto; padding: 0 16px 32px; }

button {
  font: inherit;
  font-size: 20px;
  padding: 12px 20px;
  border-radius: 10px;
  border: 0;
  background: var(--glow);
  color: #222;
  cursor: pointer;
  font-weight: 600;
}
button.small { font-size: 15px; padding: 6px 12px; background: rgba(255,255,255,0.85); }
button.secondary { background: rgba(255,255,255,0.85); }

input[type=text], input[type=password] {
  font: inherit;
  font-size: 20px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 0;
  width: 100%;
  max-width: 320px;
}

.panel { background: var(--panel); border-radius: 14px; padding: 12px; margin: 12px 0; }
.form-row { margin: 10px 0; }
.links li { margin: 12px 0; list-style: none; }
.links ul { padding: 0; }
.link-text { word-break: break-all; font-size: 14px; color: var(--muted); display: block; margin: 4px 0; }
.buttons { display: flex; gap: 8px; flex-wrap: wrap; }

.status {
  text-align: center;
  font-size: 24px;
  font-weight: 700;
  padding: 12px;
  border-radius: 12px;
  background: var(--panel);
  margin: 8px 0;
}
.status.my-turn { background: var(--glow); color: #222; animation: pulse 1.6s ease-in-out 2; }
.hint { text-align: center; color: var(--muted); font-size: 16px; min-height: 22px; margin: 4px 0; }
.error { text-align: center; color: #222; background: #ffc9c9; border-radius: 8px; padding: 8px; font-weight: 600; }

@keyframes pulse { 50% { transform: scale(1.03); } }

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-start; }
.area { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.label { font-size: 14px; color: var(--muted); text-align: center; }

.card {
  width: var(--card-w);
  height: var(--card-h);
  border-radius: 8px;
  background: #fff;
  border: 3px solid #fff;
  box-shadow: 0 2px 4px rgba(0,0,0,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  font-size: 34px;
  font-weight: 800;
  position: relative;
  user-select: none;
  flex-shrink: 0;
}
.card.c-blue { color: var(--blue); }
.card.c-green { color: var(--green); }
.card.c-red { color: var(--red); }
.card.c-sb { color: #fff; background: var(--sb); font-size: 13px; }
.card.c-sb.as-value { font-size: 34px; }
.card .sb-mark { font-size: 11px; font-weight: 700; }
.card.back { background: repeating-linear-gradient(45deg, #c92a2a, #c92a2a 6px, #e03131 6px, #e03131 12px); }
.card.empty { background: transparent; border: 3px dashed rgba(255,255,255,0.45); box-shadow: none; color: rgba(255,255,255,0.6); font-size: 14px; }
.card.clickable { cursor: pointer; }
.card.selected { transform: translateY(-10px); border-color: var(--glow); box-shadow: 0 0 0 4px var(--glow); }
.card.target { box-shadow: 0 0 0 4px var(--glow); cursor: pointer; }
.card .count {
  position: absolute; bottom: -10px; right: -10px;
  background: #222; color: #fff; font-size: 13px; border-radius: 12px; padding: 2px 7px;
}

.fan { position: relative; width: var(--card-w); }
.fan .card { position: absolute; left: 0; }
.fan .card.under { justify-content: flex-start; font-size: 17px; line-height: 1; }
.fan .card.under.c-sb { font-size: 9px; padding-top: 3px; }
.opponent .fan .card.under { font-size: 12px; }
.opponent .fan .card.under.c-sb { font-size: 7px; padding-top: 2px; }
.fan.target-pile { outline: 4px solid var(--glow); outline-offset: 3px; border-radius: 10px; cursor: pointer; }

.hand { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.hand { --card-w: 76px; --card-h: 108px; }
.hand .card { font-size: 40px; }
.hand .card.c-sb { font-size: 17px; }

.opponent { --card-w: 44px; --card-h: 62px; }
.opponent .card { font-size: 22px; border-width: 2px; }
.opponent .card.c-sb { font-size: 10px; }
.opponent-name { font-weight: 700; font-size: 18px; }
.opponent-name.moving::before { content: "▶ "; color: var(--glow); }

.table-center { display: flex; gap: 14px; justify-content: center; align-items: flex-start; flex-wrap: wrap; }

@media (max-width: 480px) {
  :root { --card-w: 54px; --card-h: 76px; }
  .card { font-size: 28px; }
  .hand { --card-w: 58px; --card-h: 84px; }
  .hand .card { font-size: 32px; }
  .hand .card.c-sb { font-size: 13px; }
  .opponent { --card-w: 40px; --card-h: 56px; }
  .row { gap: 6px; }
}

.login { max-width: 360px; margin: 40px auto; }
.lobby-head { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
.lobby-head h2 { font-size: 24px; color: var(--text); margin: 0; }
.choices { display: flex; flex-wrap: wrap; gap: 10px; }
.choice { display: inline-flex; align-items: center; gap: 8px; font-size: 20px; background: rgba(255,255,255,0.1); padding: 8px 14px; border-radius: 10px; cursor: pointer; }
.choice input { width: 24px; height: 24px; }
.games { list-style: none; padding: 0; margin: 0; }
.games li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid rgba(255,255,255,0.15); }
.games li:last-child { border-bottom: 0; }
.games li.my-game strong::before { content: "▶ "; color: var(--glow); }
.wins { font-size: 20px; font-weight: 700; margin-bottom: 8px; }
details.panel summary { cursor: pointer; font-weight: 600; font-size: 18px; }
details.panel ul { padding-left: 20px; }
button:disabled { opacity: 0.5; cursor: default; }
.games .label { text-align: left; }
