/* Karuta — picture cards on a tatami mat, under a blossom night. */
#dock { display: none; }
.ka-col { padding: 6px 10px 10px; }
.ka-table {
  --c: min((100vw - 60px) / 4, (100vh - 200px) / 6.8, 92px);
  --c: min((100vw - 60px) / 4, (100dvh - 200px) / 6.8, 92px);
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  direction: ltr; user-select: none; -webkit-user-select: none;
}
.ka-side { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; }

/* ---- the called picture in its ring ---- */
.ka-caller { position: relative; flex: none; width: calc(var(--c) * 1.5); height: calc(var(--c) * 1.5); }
.ka-ring { position: absolute; inset: 0; width: 100%; height: 100%; }
.ka-ring circle { fill: none; stroke-width: 6; }
.ka-ring__bg { stroke: rgba(251, 243, 234, 0.14); }
.ka-ring__fg { stroke: var(--w-blossom); stroke-linecap: round; }
.ka-caller.is-low .ka-ring__fg { stroke: var(--w-torii); }
.ka-call {
  position: absolute; inset: 13%; display: grid; place-items: center; border-radius: 50%;
  background: var(--w-paper); box-shadow: inset 0 0 0 3px rgba(22, 16, 38, 0.12), 0 4px 12px rgba(0, 0, 0, 0.35);
  transition: opacity 0.2s, transform 0.2s;
}
.ka-call svg { width: 70%; height: 70%; }
.ka-call.is-look { background: var(--w-indigo); animation: ka-breathe 1.3s ease-in-out infinite; }
.ka-call.is-pop { transform: scale(0.6); }
.ka-call.is-pop.is-in { transform: scale(1); transition: transform 0.22s cubic-bezier(0.3, 1.6, 0.5, 1); }
.ka-call.is-done { opacity: 0.35; transform: scale(0.9); }
@keyframes ka-breathe { 50% { transform: scale(0.93); } }

/* ---- piles and round pips ---- */
.ka-pile {
  display: flex; align-items: center; justify-content: center; gap: 6px; flex: none;
  min-width: 78px; height: 46px; padding: 0 12px; border-radius: 14px;
  background: var(--lapis-raise); box-shadow: inset 0 0 0 1.5px var(--hairline); color: var(--mist);
}
.ka-pile__icon { width: 24px; height: 24px; }
.ka-pile__icon svg { display: block; width: 100%; height: 100%; }
.ka-pile__n { font: 800 1.35rem/1 var(--font-display); color: var(--parchment); min-width: 1.2em; text-align: center; }
.ka-pile--you { color: var(--w-blossom); min-width: 120px; box-shadow: inset 0 0 0 2px var(--w-blossom); }
.ka-pile--phone { color: var(--w-gold); }
.ka-pips { display: flex; gap: 7px; justify-content: center; min-width: 78px; }
.ka-pips i { width: 14px; height: 14px; border-radius: 50%; box-shadow: inset 0 0 0 2px var(--mist-dim); }
.ka-pips i.is-done { background: var(--w-matcha); box-shadow: none; }
.ka-pips i.is-now { background: var(--w-blossom); box-shadow: 0 0 0 3px rgba(246, 166, 193, 0.28); }

/* ---- tatami mat ---- */
.ka-mat {
  display: grid; grid-template-columns: repeat(4, var(--c)); grid-auto-rows: calc(var(--c) * 1.25); gap: 6px;
  padding: 10px; border-radius: 10px; border: 5px solid #2A3A1E;
  background:
    repeating-linear-gradient(90deg, rgba(60, 80, 30, 0.16) 0 1px, transparent 1px 4px),
    linear-gradient(180deg, #B9C47A, #A6B466);
  box-shadow: 0 0 0 2px var(--w-gold), 0 10px 22px rgba(0, 0, 0, 0.45);
}
.ka-slot { position: relative; border-radius: 7px; box-shadow: inset 0 0 0 1.5px rgba(42, 58, 30, 0.18); }
.ka-card {
  position: absolute; inset: 0; display: grid; place-items: center; padding: 0; margin: 0;
  border: 3px solid #4E7A3A; border-radius: 7px; background: var(--w-paper); cursor: pointer;
  box-shadow: 0 2px 0 #2F4D22, 0 4px 7px rgba(0, 0, 0, 0.3);
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.ka-card svg { width: 82%; height: auto; pointer-events: none; }
.ka-card:focus-visible { outline: 3px solid var(--w-torii); outline-offset: 2px; }
.ka-card:active { transform: scale(0.95); }
.ka-card.is-deal { animation: ka-deal 0.32s cubic-bezier(0.2, 0.9, 0.3, 1.2) backwards; }
.ka-card.is-wrong { animation: ka-shake 0.32s; }
.ka-card.is-fly { z-index: 6; pointer-events: none; transition: transform 0.44s cubic-bezier(0.5, -0.25, 0.7, 1), opacity 0.2s ease-in 0.26s; }
.ka-card.is-phone { border-color: var(--w-torii); box-shadow: 0 0 0 4px rgba(224, 69, 47, 0.55); transition-delay: 0.2s, 0.44s; }
.ka-card.is-mine { border-color: var(--w-blossom); }
@keyframes ka-deal { from { opacity: 0; transform: translateY(-26px) rotate(-8deg) scale(0.8); } }
@keyframes ka-shake { 25% { transform: translateX(-5px) rotate(-3deg); } 75% { transform: translateX(5px) rotate(3deg); } }

/* ---- short, wide screens: caller beside the mat ---- */
@media (orientation: landscape) and (max-height: 560px) {
  .ka-table { --c: min((100vh - 124px) / 5, (100vw - 330px) / 4, 92px); flex-direction: row; gap: 16px; }
  .ka-side { flex-direction: column; width: auto; gap: 8px; }
  .ka-caller { width: calc(var(--c) * 1.7); height: calc(var(--c) * 1.7); }
  .ka-pile--you { min-width: 78px; }
}
@media (prefers-reduced-motion: reduce) {
  .ka-card.is-deal, .ka-card.is-wrong, .ka-call.is-look { animation: none; }
  .ka-card.is-fly { transition: opacity 0.15s; }
}
