/* Soroban: a wooden abacus above, the sum and a number pad below. Sizes inside the frame are in em:
   1em = one bead's height, set from the space available by game.js. */

body[data-game="soroban"] .fa-dock { display: none; }

.sb-wrap { position: absolute; top: 0; right: 0; bottom: 0; left: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 8px 12px calc(10px + env(safe-area-inset-bottom, 0px)); direction: ltr; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
.sb-top { flex: 1 1 auto; min-height: 0; width: 100%; max-width: 560px; display: flex; flex-direction: column; gap: 8px; }
.sb-bottom { flex: none; width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 6px; }

/* clock, time bar and the five level blossoms */
.sb-hud { flex: none; display: flex; align-items: center; gap: 10px; }
.sb-time { min-width: 2.6em; font: 800 1.05rem/1 var(--font-display); color: var(--parchment); font-variant-numeric: tabular-nums; }
.sb-bar { flex: 1 1 auto; height: 8px; border-radius: 4px; background: rgba(251, 243, 234, 0.12); overflow: hidden; }
.sb-bar i { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, #F6A6C1, #FBD3E0); transform-origin: 0 50%; }
.sb-hud.is-low .sb-bar i { background: #E0452F; }
.sb-hud.is-low .sb-time { color: #F58C7B; }
.sb-pips { display: flex; gap: 5px; }
.sb-pips i { width: 11px; height: 11px; border-radius: 50% 50% 50% 8%; transform: rotate(45deg); background: rgba(251, 243, 234, 0.14); transition: background 0.2s; }
.sb-pips i.is-on { background: #F6A6C1; box-shadow: 0 0 8px rgba(246, 166, 193, 0.55); }
.sb-pips.is-up { animation: sb-up 0.5s ease; }
@keyframes sb-up { 40% { transform: scale(1.35); } }

/* the soroban */
.sb-box { flex: 1 1 auto; min-height: 0; display: flex; align-items: center; justify-content: center; }
.sb-frame { font-size: 24px; padding: 0.42em; border-radius: 0.36em; background: linear-gradient(160deg, #6B3F22, #47270F 60%, #3A1F0C); box-shadow: 0 0.3em 0.9em rgba(0, 0, 0, 0.45), inset 0 0.06em 0 rgba(255, 220, 170, 0.35), inset 0 -0.08em 0 rgba(0, 0, 0, 0.4); }
.sb-rods { position: relative; display: flex; padding: 0 0.1em; border-radius: 0.16em; background: linear-gradient(#1E1530, #161026); box-shadow: inset 0 0.1em 0.3em rgba(0, 0, 0, 0.6); }
.sb-rod { position: relative; width: 1.9em; height: 8.3em; }
.sb-stick { position: absolute; left: 50%; top: 0; width: 0.13em; height: 7.4em; margin-left: -0.065em; background: linear-gradient(90deg, #8E7B55, #E3D2A4 45%, #8E7B55); }
.sb-beam { position: absolute; left: 0; right: 0; top: 2.05em; height: 0.34em; z-index: 1; background: linear-gradient(#FBF3EA, #D9CDB8); box-shadow: 0 0.05em 0.1em rgba(0, 0, 0, 0.5); }
.sb-dot { position: absolute; left: 50%; top: 2.14em; z-index: 2; width: 0.16em; height: 0.16em; margin-left: -0.08em; border-radius: 50%; background: #E0452F; }
.sb-bead { position: absolute; left: 0.12em; width: 1.66em; height: 0.96em; -webkit-clip-path: polygon(0 50%, 24% 0, 76% 0, 100% 50%, 76% 100%, 24% 100%); clip-path: polygon(0 50%, 24% 0, 76% 0, 100% 50%, 76% 100%, 24% 100%); background: linear-gradient(#B98A55 0%, #8C5C2E 46%, #5E3817 54%, #7A4C22 100%); transition: transform 0.16s cubic-bezier(0.3, 1.5, 0.6, 1), filter 0.16s; filter: brightness(0.72) saturate(0.8); will-change: transform; }
.sb-bead.is-on { filter: none; background: linear-gradient(#F2C98A 0%, #D9A45B 46%, #9A6226 54%, #C28A45 100%); }
.sb-bead--h { top: 0.05em; }
.sb-bead--e { top: 2.42em; }
.sb-digit { position: absolute; left: 0; right: 0; bottom: 0.08em; text-align: center; font: 800 0.62em/1 var(--font-display); color: rgba(201, 190, 220, 0.45); font-variant-numeric: tabular-nums; }
.sb-digit.is-on { color: #FBD3E0; }

/* the sum */
.sb-sum { position: relative; display: flex; align-items: center; justify-content: center; gap: 0.4em; min-height: 54px; padding: 4px 12px; border-radius: 14px; background: #FBF3EA; color: #161026; font: 800 1.7rem/1 var(--font-display); font-variant-numeric: tabular-nums; box-shadow: 0 4px 0 rgba(0, 0, 0, 0.28); }
.sb-eq { color: #7A4E9E; }
.sb-ans { min-width: 2.3em; padding: 0.16em 0.3em; border-radius: 9px; text-align: center; background: #fff; box-shadow: inset 0 0 0 2px #2E3A7C; color: #2E3A7C; }
.sb-ans.is-empty { color: rgba(46, 58, 124, 0.35); }
.sb-sum.is-right { animation: sb-right 0.35s ease; }
.sb-sum.is-wrong { animation: sb-wrong 0.3s ease; }
.sb-sum.is-wrong .sb-ans { box-shadow: inset 0 0 0 2px #E0452F; color: #E0452F; }
@keyframes sb-right { 30% { background: #D5E8B4; transform: scale(1.03); } }
@keyframes sb-wrong { 20% { transform: translateX(-7px); } 45% { transform: translateX(6px); } 70% { transform: translateX(-4px); } }
.sb-pop { position: absolute; right: 10px; top: -4px; font: 800 1rem/1 var(--font-display); color: #5B7D2B; pointer-events: none; animation: sb-pop 0.7s ease-out forwards; }
@keyframes sb-pop { from { opacity: 1; transform: translateY(8px); } to { opacity: 0; transform: translateY(-22px); } }
.sb-hint { min-height: 1.2em; text-align: center; font-size: 0.82rem; line-height: 1.2; color: var(--mist); }

/* the number pad */
.sb-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.sb-key { height: clamp(44px, 7.2vh, 60px); border: 0; border-radius: 12px; background: var(--lapis-raise); color: var(--parchment); font: 800 1.45rem/1 var(--font-display); box-shadow: inset 0 0 0 1px var(--hairline), 0 3px 0 rgba(0, 0, 0, 0.32); cursor: pointer; touch-action: manipulation; display: flex; align-items: center; justify-content: center; }
.sb-key--fn { background: transparent; color: var(--gold); box-shadow: inset 0 0 0 1px var(--hairline); }
.sb-key svg { width: 26px; height: 26px; }
.sb-key.is-down, .sb-key:active { transform: translateY(2px); background: #F6A6C1; color: #161026; box-shadow: none; }
.sb-key:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* Wide and short (a phone on its side): soroban on the left, sum and pad on the right. */
@media (orientation: landscape) and (max-height: 560px) {
  .sb-wrap { flex-direction: row; align-items: stretch; justify-content: center; gap: 16px; padding: 6px 14px; }
  .sb-top { flex: 1 1 0; }
  .sb-bottom { flex: 0 1 300px; justify-content: center; gap: 5px; }
  .sb-sum { min-height: 46px; font-size: 1.4rem; }
  .sb-key { height: clamp(40px, 13vh, 54px); }
}
@media (max-height: 600px) and (orientation: portrait) {
  .sb-wrap { gap: 5px; padding-top: 5px; }
  .sb-top { gap: 4px; }
  .sb-sum { min-height: 46px; font-size: 1.45rem; }
  .sb-hint { font-size: 0.75rem; }
  .sb-key { height: 42px; font-size: 1.3rem; }
  .sb-bottom { gap: 4px; }
  .sb-pad { gap: 5px; }
}
@media (max-width: 360px) {
  body[data-game="soroban"] .fa-title { font-size: 0.95rem; }
  body[data-game="soroban"] .fa-chip { min-width: 0; padding-left: 9px; padding-right: 9px; }
}
/* Short phones (320 x 568): a tighter start panel, so Play shows without scrolling. */
@media (max-height: 600px) {
  body[data-game="soroban"] .kit-start .fa-panel { padding: 14px 18px; }
  body[data-game="soroban"] .kit-start .fa-panel__art { margin: 0 0 6px; }
  body[data-game="soroban"] .kit-start .kit-art { max-width: 96px; border-radius: 12px; }
  body[data-game="soroban"] .kit-start .fa-panel__title { margin: 2px 0 4px; font-size: 1.5rem; }
  body[data-game="soroban"] .kit-start .fa-panel__text { margin-bottom: 8px; font-size: 0.86rem; line-height: 1.3; }
  body[data-game="soroban"] .kit-start .fa-panel__body { margin-bottom: 10px; }
  body[data-game="soroban"] .kit-start .fa-howto { gap: 4px; margin: 0; font-size: 0.82rem; line-height: 1.25; }
}
@media (prefers-reduced-motion: reduce) {
  .sb-bead { transition-duration: 0.01s; }
  .sb-sum.is-right, .sb-sum.is-wrong, .sb-pips.is-up { animation: none; }
}
