/* ==========================================================================
   Yamato.com — Hanafuda Koi-Koi table
   The table is a tatami-green felt with the field (場) laid out in the middle,
   your hand along the bottom and both capture piles sorted by kind, the way a
   real game is arranged on the floor.
   ========================================================================== */

:root {
  --hf-felt-1: #2f6b4f;
  --hf-felt-2: #1d4733;
  --hf-felt-line: rgba(255, 255, 255, 0.14);
  --hf-gold: #d4a017;
  --hf-red: #a3243b;
  --hf-select: #f5c518;
}

/* ------------------------------------------------------------------ cards */
.hf-card {
  --hf-w: 62px;
  width: var(--hf-w);
  flex: 0 0 auto;
  line-height: 0;
  border-radius: 7px;
  transition: transform 0.16s ease, box-shadow 0.16s ease, filter 0.16s ease;
  position: relative;
}

.hf-card .hf-svg { width: 100%; height: auto; display: block; border-radius: 7px; }

.hf-sm { --hf-w: 42px; }
.hf-md { --hf-w: 62px; }
.hf-lg { --hf-w: 84px; }

.hf-selectable { cursor: pointer; }
.hf-selectable:hover { transform: translateY(-8px); box-shadow: 0 10px 22px rgba(0, 0, 0, 0.35); z-index: 4; }

.hf-selected {
  transform: translateY(-12px);
  box-shadow: 0 0 0 3px var(--hf-select), 0 12px 26px rgba(0, 0, 0, 0.4);
  z-index: 5;
}

/* A card the rules will not let you take right now. */
.hf-dimmed { filter: grayscale(0.55) brightness(0.78); }

/* Highlight the field cards that match the card being played. */
.hf-matchable { box-shadow: 0 0 0 3px var(--hf-gold), 0 6px 16px rgba(0, 0, 0, 0.3); }
.hf-matchable::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 10px;
  border: 2px dashed rgba(245, 197, 24, 0.85);
  pointer-events: none;
  animation: hfPulse 1.4s ease-in-out infinite;
}
@keyframes hfPulse { 50% { opacity: 0.35; } }

.hf-just-taken { animation: hfTake 0.6s ease; }
@keyframes hfTake {
  0% { transform: scale(1.16); box-shadow: 0 0 0 4px var(--hf-gold); }
  100% { transform: scale(1); box-shadow: none; }
}

/* ------------------------------------------------------------------ table */
.hf-table {
  position: relative;
  border-radius: 14px;
  padding: 16px;
  background:
    radial-gradient(120% 120% at 50% 30%, var(--hf-felt-1), var(--hf-felt-2) 75%, #143324 100%);
  box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.35), 0 12px 34px rgba(0, 0, 0, 0.2);
  display: grid;
  gap: 12px;
  min-height: 480px;
}

.hf-seat {
  display: grid;
  gap: 7px;
  padding: 9px 12px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.16);
}

.hf-seat-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  color: #f2ead8;
  font-size: 13.5px;
}

.hf-seat-name { font-weight: 700; }

.hf-seat-badge {
  font-family: 'Shippori Mincho B1', serif;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  letter-spacing: 0.06em;
}
.hf-seat-badge.is-oya { background: var(--hf-gold); color: #2a2010; font-weight: 700; }
.hf-seat.is-turn { box-shadow: inset 0 0 0 2px var(--hf-select); }

.hf-seat-points { margin-left: auto; font-variant-numeric: tabular-nums; }
.hf-seat-points b { color: var(--hf-gold); font-size: 17px; }

.hf-hand, .hf-field-row, .hf-pile-row { display: flex; flex-wrap: wrap; gap: 5px; }

.hf-hand { min-height: 96px; align-items: flex-end; }

/* The field sits in the centre, on a slightly lighter panel. */
.hf-field {
  border-radius: 11px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--hf-felt-line);
  min-height: 176px;
}

.hf-field-label {
  font-family: 'Shippori Mincho B1', serif;
  font-size: 11.5px;
  letter-spacing: 0.16em;
  color: rgba(255, 255, 255, 0.55);
  margin-bottom: 9px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.hf-field-label .hf-deck-count { margin-left: auto; font-family: system-ui, sans-serif; }

.hf-field-row { justify-content: center; }

/* Capture piles, grouped by kind so the yaku are readable at a glance. */
.hf-pile {
  display: grid;
  gap: 5px;
  padding: 8px 10px;
  border-radius: 9px;
  background: rgba(0, 0, 0, 0.2);
}

.hf-pile-group {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.hf-pile-kind {
  font-family: 'Shippori Mincho B1', serif;
  font-size: 11px;
  width: 34px;
  flex: 0 0 34px;
  color: rgba(255, 255, 255, 0.62);
}

/* Overlap the chaff so a ten-card pile stays compact. */
.hf-pile-group.is-stacked .hf-card + .hf-card { margin-left: -30px; }
.hf-pile-group.is-stacked .hf-card:hover { margin-right: 24px; z-index: 6; }

/* --------------------------------------------------------------- yaku list */
.hf-yaku {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.hf-yaku-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  background: rgba(212, 160, 23, 0.18);
  color: #f7dd93;
  border: 1px solid rgba(212, 160, 23, 0.45);
  font-family: 'Shippori Mincho B1', serif;
}
.hf-yaku-chip b { font-family: system-ui, sans-serif; color: #fff; }
.hf-yaku-chip.is-new { animation: hfYakuIn 0.5s ease; background: rgba(212, 160, 23, 0.4); }
@keyframes hfYakuIn { from { transform: scale(0.7); opacity: 0; } }

/* -------------------------------------------------------------- decisions */
.hf-decision {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(10, 26, 18, 0.72);
  backdrop-filter: blur(3px);
  border-radius: 14px;
  padding: 20px;
}

.hf-decision-box {
  background: var(--ya-kinari, #faf6ee);
  border-radius: 13px;
  padding: 24px 26px;
  max-width: 460px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
}

.hf-decision-box h3 {
  font-family: 'Yuji Syuku', 'Shippori Mincho B1', serif;
  font-size: 26px;
  color: var(--hf-red);
  margin-bottom: 6px;
}

.hf-decision-box .hf-decision-sub { font-size: 14px; color: #55503f; margin-bottom: 14px; }

.hf-decision-yaku {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin-bottom: 18px;
}
.hf-decision-yaku .hf-yaku-chip {
  background: rgba(163, 36, 59, 0.1);
  color: var(--hf-red);
  border-color: rgba(163, 36, 59, 0.3);
}
.hf-decision-yaku .hf-yaku-chip b { color: #2a2620; }

.hf-decision-buttons { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

.hf-btn-koikoi, .hf-btn-shobu {
  border: none;
  border-radius: 9px;
  padding: 13px 26px;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  font-family: 'Shippori Mincho B1', serif;
  min-width: 132px;
  transition: filter 0.15s, transform 0.1s;
}
.hf-btn-koikoi { background: var(--hf-gold); color: #2a2010; }
.hf-btn-shobu { background: var(--hf-red); color: #fff; }
.hf-btn-koikoi:hover, .hf-btn-shobu:hover { filter: brightness(1.08); }
.hf-btn-koikoi:active, .hf-btn-shobu:active { transform: translateY(1px); }
.hf-btn-sub { display: block; font-size: 11.5px; font-weight: 400; opacity: 0.8; margin-top: 2px; }

/* ----------------------------------------------------------- announcement */
.hf-shout {
  position: absolute;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%);
  z-index: 24;
  font-family: 'Yuji Syuku', serif;
  font-size: clamp(40px, 9vw, 84px);
  color: var(--hf-gold);
  text-shadow: 0 4px 22px rgba(0, 0, 0, 0.7);
  pointer-events: none;
  animation: hfShout 1.3s ease forwards;
}
@keyframes hfShout {
  0% { transform: translate(-50%, -50%) scale(0.4); opacity: 0; }
  22% { transform: translate(-50%, -50%) scale(1.1); opacity: 1; }
  74% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -62%) scale(1); opacity: 0; }
}

/* ------------------------------------------------------------- round track */
.hf-rounds {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: rgba(255, 255, 255, 0.72);
}
.hf-round-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
}
.hf-round-dot.is-done { background: var(--hf-gold); }
.hf-round-dot.is-current { background: #fff; box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.25); }

@media (max-width: 640px) {
  .hf-md { --hf-w: 48px; }
  .hf-table { padding: 11px; gap: 9px; min-height: 0; }
  .hf-field { padding: 10px; min-height: 138px; }
  .hf-hand { min-height: 76px; }
  .hf-pile-kind { width: 26px; flex-basis: 26px; font-size: 10px; }
}

/* Lacquered paper edges and wool cloth, shared by all game modes. */
.hf-card { border-radius:3px; box-shadow:0 2px 0 #21180f,0 3px 0 #443529,0 5px 7px #0005; }
.hf-card .hf-svg { border-radius:3px; }
.hf-table { border-radius:10px; border:7px solid #49382b; outline:1px solid #b49a65; background:linear-gradient(#19392b18,#071e2390),url('/images/art/materials/felt.webp') center/cover; box-shadow:inset 0 0 50px #061c2780,inset 0 0 0 1px #d9c49370,0 6px 0 #2a251f,0 14px 28px #20302325; }
.hf-seat { background:#0a241e38; border:1px solid #f1e0b51c; border-radius:6px; }
.hf-field { border-radius:6px; background:#fff4d206; border-color:#d9c49344; box-shadow:inset 0 0 30px #001d1918; }
.hf-pile { border-radius:4px; background:#081f1930; }
.hf-card.hf-selected,.hf-card.hf-matchable { box-shadow:0 0 0 2px #e6c479,0 3px 0 #43321d,0 8px 16px #0006; }
.hf-seat.is-turn { box-shadow:inset 0 0 0 1px #e6c479; background:#e6c4790c; }
@media(max-width:640px) { .hf-table {border-width:4px;} }

/* The card's corner radius follows its width — the same 10/120 the face is cut
   to — so its thickness, its shadow and any highlight trace the card itself
   instead of showing a corner it does not have. The dark band beneath is the
   board core of a real fuda, seen edge on. */
.hf-card { border-radius: calc(var(--hf-w) * 0.0833); box-shadow: 0 1px 0 #2a1d12, 0 2px 0 #120c08, 0 3px 5px #00000045, 0 8px 14px -6px #00000050; }
.hf-card .hf-svg { border-radius: inherit; }
.hf-selectable:hover { box-shadow: 0 1px 0 #2a1d12, 0 2px 0 #120c08, 0 12px 22px -4px #00000059; }
.hf-card.hf-selected, .hf-card.hf-matchable { box-shadow: 0 0 0 2px #e6c479, 0 2px 0 #120c08, 0 10px 18px -4px #00000066; }
.hf-matchable::after { border-radius: calc(var(--hf-w) * 0.0833 + 4px); }

/* An empty place on the field keeps its size so the other cards stay put. */
.hf-card.hf-slot { visibility: hidden; box-shadow: none; }
/* A hand card that can capture carries a small gold mark below it. */
.hf-seat-you .hf-card.hf-can-take::before {
  content: ''; position: absolute; left: 50%; bottom: -7px; width: 18%; min-width: 8px; height: 3px;
  transform: translateX(-50%); border-radius: 2px; background: #e6c479; box-shadow: 0 0 6px #e6c47999;
}
