/* GENERATED FILE — edit css/style.css or css/modules/*.css, then run npm run build:css. */

/* ---- css/participant-editor.css ---- */
/* Common behavior and hit-area contract, with each game retaining its palette. */
.ug-participant-roster,.ug-participant-row {min-width:0;}
.ug-participant-row {align-items:center;}
.ug-participant-name {min-width:0;max-width:100%;}
.ug-participant-avatar,.ug-participant-remove {position:relative;touch-action:manipulation;flex-shrink:0;}
.ug-participant-avatar:not(:disabled) {cursor:pointer;}
.ug-participant-remove:not(:disabled) {cursor:pointer;}
.ug-participant-avatar::after,.ug-participant-remove::after {
  content:'';position:absolute;top:50%;left:50%;width:max(44px,100%);height:max(44px,100%);
  transform:translate(-50%,-50%);pointer-events:auto;
}
.ug-participant-row :is(input,button):focus-visible {outline:3px solid #d7eaa5;outline-offset:2px;}
@media(prefers-reduced-motion:reduce){.ug-participant-row *{transition:none!important;animation:none!important;}}


/* Dice-style participant editor shared by Pirate, Bomb, Reaction, and Timer.
   Rows reuse ParticipantEditor; palette is deliberately theme-aware. */
body .ug-dice-style-roster.ug-participant-roster {
  display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;
  align-items:stretch;margin-top:18px;margin-bottom:18px;min-width:0;
}
body .ug-dice-style-roster .ug-dice-style-row.ug-participant-row {
  display:flex;flex-direction:row;align-items:center;gap:7px;min-width:0;
  padding:7px 8px;border:1px solid #59787a;border-radius:12px;
  background:#1b343c;color:#f2f7ef;transition:border-color .15s;
}
body .ug-dice-style-roster .ug-dice-style-row:focus-within {
  border-color:#d5ef96;background:#24424a;
}
body .ug-dice-style-roster .ug-dice-style-row .ug-participant-number {
  flex:0 0 20px;min-width:20px;text-align:center;font-size:11px;
  font-weight:800;color:#c9dcac;
}
body .ug-dice-style-roster .ug-dice-style-row .ug-participant-avatar {
  display:grid;place-items:center;flex:0 0 44px;width:44px;height:44px;
  min-height:44px;padding:0;margin:0;border:1px solid #76949a;
  border-radius:11px;background:#39565c;color:#fff;
  font:25px/1 system-ui,sans-serif;cursor:pointer;
}
body .ug-dice-style-roster .ug-dice-style-row input.ug-participant-name {
  flex:1;min-width:0;width:100%;min-height:40px;max-width:100%;
  padding:6px 2px;margin:0;border:0;border-radius:0;outline:0;
  background:transparent;color:#f8fff3;box-shadow:none;
  font-size:16px;font-weight:750;text-overflow:ellipsis;
}
body .ug-dice-style-roster .ug-dice-style-row input.ug-participant-name::placeholder {
  color:#b7c9c1;opacity:1;
}
body .ug-dice-style-roster .ug-dice-style-row .ug-participant-remove {
  flex:0 0 44px;display:grid;place-items:center;
  width:44px;min-width:44px;min-height:44px;padding:0;margin:0;
  border:0;border-radius:7px;background:transparent;color:#dceae2;
  font-size:23px;line-height:1;cursor:pointer;
}
body .ug-dice-style-roster .ug-dice-style-row .ug-participant-remove:not(:disabled):hover {
  color:#fff;background:#734c50;
}
body .ug-dice-style-roster .ug-dice-style-row .ug-participant-remove:disabled {
  opacity:.3;cursor:not-allowed;
}
body .ug-dice-style-roster .ug-dice-style-controls {
  grid-column:1/-1;
}
body .ug-dice-style-controls {
  display:flex;align-items:center;justify-content:flex-start;
  flex-wrap:wrap;gap:12px;min-width:0;margin-top:4px;
}
body .ug-dice-style-controls .ug-dice-style-add {
  min-height:44px;padding:9px 15px;border:1px solid #d7f497;
  border-radius:10px;background:#d7f497;color:#1c362d;
  font-size:13px;font-weight:800;cursor:pointer;
}
body .ug-dice-style-controls .ug-dice-style-add:disabled {opacity:.5;cursor:not-allowed;}
body .ug-dice-style-controls .ug-dice-style-count {font-size:12px;color:#c4dbce;}
html[data-theme="light"] body .ug-dice-style-roster .ug-dice-style-row.ug-participant-row {
  background:#f2f7f2;color:#244738;border-color:#bdd2c4;
}
html[data-theme="light"] body .ug-dice-style-roster .ug-dice-style-row.ug-participant-row:focus-within {
  background:#fff;border-color:#568771;box-shadow:0 0 0 2px #56877126;
}
html[data-theme="light"] body .ug-dice-style-roster .ug-dice-style-row .ug-participant-number {color:#426854;}
html[data-theme="light"] body .ug-dice-style-roster .ug-dice-style-row .ug-participant-avatar {
  background:#e2f0e7;color:#234737;border-color:#adccba;
}
html[data-theme="light"] body .ug-dice-style-roster .ug-dice-style-row input.ug-participant-name {color:#244738;}
html[data-theme="light"] body .ug-dice-style-roster .ug-dice-style-row input.ug-participant-name::placeholder {color:#617b6c;}
html[data-theme="light"] body .ug-dice-style-roster .ug-dice-style-row .ug-participant-remove {
  color:#496759;background:#e9f2ec;border:1px solid #c4d8ca;
}
html[data-theme="light"] body .ug-dice-style-roster .ug-dice-style-row .ug-participant-remove:not(:disabled):hover {
  color:#803c31;background:#fbe9e4;border-color:#dfb8ac;
}
html[data-theme="light"] body .ug-dice-style-controls .ug-dice-style-add {
  color:#fff;background:#2b6246;border-color:#2b6246;
}
html[data-theme="light"] body .ug-dice-style-controls .ug-dice-style-count {color:#4b6c58;}
@media(max-width:700px){
  body .ug-dice-style-roster.ug-participant-roster {grid-template-columns:minmax(0,1fr);gap:8px;}
}
@media(max-width:480px){
  body .ug-dice-style-roster .ug-dice-style-row.ug-participant-row {gap:5px;padding:6px;}
  body .ug-dice-style-roster .ug-dice-style-row .ug-participant-number {flex-basis:18px;min-width:18px;}
}

/* Dice-style rosters keep their own palette against legacy high-specificity form rules. */
html[data-theme="light"] body .ug-dice-style-roster .ug-dice-style-row.ug-participant-row{
 background:#f3f8f4!important;color:#244738!important;border-color:#bdd2c4!important;
}
html[data-theme="light"] body .ug-dice-style-roster .ug-dice-style-row.ug-participant-row:focus-within{
 background:#f9fcfa!important;border-color:#568771!important;
}
html[data-theme="light"] body .ug-dice-style-roster .ug-dice-style-row input.ug-participant-name{
 background:transparent!important;color:#244738!important;-webkit-text-fill-color:#244738;
}
html[data-theme="light"] body .ug-dice-style-roster .ug-dice-style-row input.ug-participant-name::placeholder{
 color:#607c6b!important;-webkit-text-fill-color:#607c6b;
}
html[data-theme="dark"] body .ug-dice-style-roster .ug-dice-style-row.ug-participant-row{
 background:#192f38!important;color:#f1f7ed!important;border-color:#557476!important;
}
html[data-theme="dark"] body .ug-dice-style-roster .ug-dice-style-row.ug-participant-row:focus-within{
 background:#203b44!important;border-color:#d5ef96!important;
}
html[data-theme="dark"] body .ug-dice-style-roster .ug-dice-style-row input.ug-participant-name{
 background:transparent!important;color:#f8fff1!important;-webkit-text-fill-color:#f8fff1;
}
html[data-theme="dark"] body .ug-dice-style-roster .ug-dice-style-row input.ug-participant-name::placeholder{
 color:#b7cda9!important;-webkit-text-fill-color:#b7cda9;
}
html[data-theme="dark"] body .ug-dice-style-roster .ug-dice-style-row .ug-participant-number{
 color:#c5ddb3!important;
}
html[data-theme="dark"] body .ug-dice-style-roster .ug-dice-style-row .ug-participant-remove{
 background:transparent!important;color:#dceae2!important;border:0!important;
}
html[data-theme="dark"] body .ug-dice-style-roster .ug-dice-style-row .ug-participant-remove:hover:not(:disabled){
 background:#65434b!important;color:#fff!important;
}
html[data-theme="dark"] body .ug-dice-style-roster .ug-dice-style-row .ug-participant-avatar{
 background:#35545b!important;color:#fff;border-color:#658681!important;
}
html[data-theme="dark"] body .players.ug-dice-style-roster .ug-dice-style-count{
 color:#39524a;
}

/* ---- css/modules/variables.css ---- */
/* Variables */
:root {
  --color-primary: #ff00ff;
  --color-primary-rgb: 255, 0, 255;
  --color-secondary: #00ffff;
  --color-accent: #4CAF50;
  --color-dark: #0f0f12;
  --color-darker: #070709;
  --color-text: #ffffff;
  --color-text-muted: rgba(255, 255, 255, 0.7);
  --glow-primary: 0 0 10px rgba(255, 0, 255, 0.7), 0 0 20px rgba(255, 0, 255, 0.5);
  --glow-secondary: 0 0 10px rgba(0, 255, 255, 0.7), 0 0 20px rgba(0, 255, 255, 0.5);
}

/* ---- css/modules/layout.css ---- */
/* Base styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body, html {
  font-family: 'Noto Sans KR', 'Montserrat', sans-serif;
  background-color: var(--color-darker);
  color: var(--color-text);
  line-height: 1.6;
  overflow-x: hidden;
  height: 100%;
  width: 100%;
  position: relative;
  margin: 0;
  padding: 0;
}

/* Noise overlay */
.noise-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
  pointer-events: none;
  opacity: 0.05;
  background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAECElEQVRoQ+WaTYhcRRTHf69ndjIbNdmEJMQsQSPEr0lATVAxiVm/UgQXJLIomBAximLEEMWNoKD4samriSiBeNBsguBBDEhUjCIuS4K73f9iXWcm/VRVd9X73dVVb6Z7pnvmDdOweXP//3r/OfXq1atSpKH4V4+kIBIpyD7gIPAk8GpTzEw5SHRYQwGLwGFgMDhbBB4C9je9VdpRCO1AkW7m+n54g3PBmZeAw8CRprdaZnMQZBB4Hvi0rOV1LucR4M0mQEJMCrJMYL4CbgVuAL4BXgAeB06W8UxdIBHmJPA0sB14F3gaeAO4AXgDOAW81Xij2SASsRngy8Dt/wFuBKLTHATeD8C/DyiMp4FvW/HMRtFIKohoQoDcBnwPzAGngE+A08B5QKA8AtzYCoBVAYkw7wIPA0+NabmbgSXgQ0C/PQfcDjjg4xaurzciaTDnAA+cC/zg+7EUTCQn1Uz8A1wfACzXoRIFyQMRzByQnL4WVL8MfAZ8DKwHdgIPAhrpJeBi4JbgF6XdZpUhVgskPVJN2bQmQLofV2iCZrRNK0LZtIW0B5J6YqPBPFhQrTNASLnVyuQmTW8Dxo3MMPAt8FFG3DuAg0DANCa1QArDLMEHpg3YbCMwLbCmkiuiOxkn9oC0ALuCB8xUGbgZQWQWUXs9BUw54Fk9sWXB5IQVK9CWA+lJI4kRb1FVnS7nnWZfR+qApCA+2/WAEW7oZs12lBQDmTbMEpxlE6bGEDqxNZVKJDfbPSF9zQK+S9p0kC5w3Wp7Jq89ykGaAZYD5g5Ybdd46qSe+qDXiqRHd9BdwBlgvY4hCGZGJaMWdHewvW1Ue6MWA4ndMx3ACdQD5oBBCVHtd7wHNOt2ANcJcMAx4ESo9lEBlTY0rkrbtNaA9IIbFZlRgDQYLfN6QdwpVCFDa2YLhZL2a7XjdKQwiHaXzLU3tq03Q9pA1fJLdCEEG9cRfZhtd3C3lm1d4DLQccDxAHB+tUGigpRIcqWN14l1O0OA2OZt24b9L5UUcKEqgHKQIkPZNLtDMHpvBYhzYQoTXWg11ZJtqOxrDkiZ9YlA1NI2bA6bxZXO5IJULUpnwdYG2/Yw2+7gVsuKqlUEXCgiJkgPmA0FqQvUbdcv4YGYKHkgeSDaXtmSkbM6tlLZMpHdChGXdwxkouktzwNxT2k98KvZQRwMy55F4HLVF41HQQYhfGahTQ2L16vWNZCwrO8Fvm0EQHKzlYBMS6PLtofAfPDlGwRFzb6aHYFqyVECMzSQzSZ6cQRqbsROW6Yxktp/mGJ/RQF+UE0AAAAASUVORK5CYII=');
}

/* Header styles */
.site-header {
  background-color: var(--color-dark);
  padding: 15px 30px;
  position: fixed;
  width: 100%;
  top: 0;
  left: 0;
  z-index: 1000;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid var(--color-primary);
  box-shadow: 0 0 20px rgba(255, 0, 255, 0.3);
}

.logo {
  display: flex;
  align-items: center;
}

.logo-divider {
  width: 1px;
  height: 20px;
  background: var(--color-text-muted);
  margin: 0 15px;
}

.neon-text {
  color: var(--color-primary);
  font-weight: bold;
  text-shadow: var(--glow-primary);
  transition: all 0.3s ease;
}

.neon-text-alt {
  color: var(--color-secondary);
  font-weight: bold;
  text-shadow: var(--glow-secondary);
  transition: all 0.3s ease;
}

.neon-text:hover, .neon-text-alt:hover {
  transform: scale(1.05);
}

.sponsor {
  font-size: 0.9rem;
  color: var(--color-text-muted);
}

.ios-hidden {
  display: inline;
}

.highlight {
  color: var(--color-accent);
  font-weight: bold;
}

/* Hamburger menu styles */
.hamburger-menu {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: 30px;
  height: 24px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  z-index: 10;
}

.hamburger-line {
  width: 100%;
  height: 3px;
  background-color: var(--color-primary);
  transition: all 0.3s ease;
  box-shadow: var(--glow-primary);
}

.hamburger-menu:hover .hamburger-line {
  background-color: var(--color-accent);
  box-shadow: var(--glow-secondary);
}

/* Main Menu (모달 메뉴) */
.main-menu-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.85);
  z-index: 2000;
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  overflow-y: hidden;
}

.menu-modal-content {
  position: relative;
  width: 90%;
  max-width: 600px;
  background-color: var(--color-dark);
  margin: 10vh auto;
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 0 30px rgba(255, 0, 255, 0.3);
  border: 1px solid rgba(255, 0, 255, 0.2);
  animation: modal-in 0.5s forwards;
  max-height: 80vh;
  overflow-y: auto;
}

.menu-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 15px;
  margin-bottom: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.menu-modal-header h2 {
  color: var(--color-primary);
  margin: 0;
  font-size: 1.8rem;
  text-shadow: var(--glow-primary);
}

/* New menu buttons style */
.menu-buttons {
  display: grid;
  grid-template-columns: 1fr;
  gap: 15px;
  margin-bottom: 25px;
}

.menu-button {
  display: flex;
  align-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 0, 255, 0.2);
  border-radius: 8px;
  color: var(--color-text);
  cursor: pointer;
  transition: all 0.3s;
  text-align: left;
  font-size: 1.2rem;
}

.menu-button:hover {
  background-color: rgba(255, 0, 255, 0.1);
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(255, 0, 255, 0.2);
  color: var(--color-primary);
}

.menu-button-icon {
  font-size: 1.5rem;
  margin-right: 15px;
  display: inline-block;
}

.menu-button-text {
  font-weight: bold;
}

.menu-content {
  padding: 0 10px;
  animation: fade-in 0.3s ease;
  margin-top: 15px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 20px;
}

.supporter-section, .contact-section {
  padding: 10px 0;
}

.supporter-section p, .contact-section p {
  margin-bottom: 20px;
  line-height: 1.6;
}

.supporter-credits {
  margin-top: 30px;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.supporter-credits h3 {
  color: var(--color-primary);
  margin-bottom: 10px;
}

.btn-primary {
  display: inline-block;
  padding: 12px 24px;
  background: linear-gradient(to bottom right, var(--color-primary), var(--color-secondary));
  color: white;
  border: none;
  border-radius: 5px;
  font-weight: bold;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  transition: all 0.3s;
  margin: 10px 0;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(255, 0, 255, 0.4);
}

/* 모달 공통 스타일 */
.game-help-modal, .credits-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2100;
  background-color: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

.help-modal-content, .credits-content {
  background-color: var(--color-dark);
  margin: 5vh auto;
  padding: 20px;
  border-radius: 10px;
  max-width: 800px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 0 30px rgba(255, 0, 255, 0.3);
  border: 1px solid rgba(255, 0, 255, 0.2);
  animation: modal-in 0.5s forwards;
}

.help-modal-header, .credits-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 15px;
  margin-bottom: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.help-modal-header h2, .credits-header h2 {
  color: var(--color-primary);
  margin: 0;
  font-size: 1.8rem;
  text-shadow: var(--glow-primary);
}

.close-modal-button {
  font-size: 24px;
  color: var(--color-text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.3s;
}

.close-modal-button:hover {
  color: var(--color-primary);
  transform: rotate(90deg);
}

.back-button {
  font-size: 24px;
  color: var(--color-text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.3s;
  margin-right: 15px;
}

.back-button:hover {
  color: var(--color-primary);
}

/* 게임 설명 카테고리 버튼 */
.help-category-buttons {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 15px;
  margin-bottom: 20px;
}

.help-category-button {
  display: flex;
  align-items: center;
  padding: 15px;
  background-color: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: var(--color-text);
  cursor: pointer;
  transition: all 0.3s;
}

.help-category-button:hover {
  background-color: rgba(255, 0, 255, 0.1);
  border-color: var(--color-primary);
  transform: translateY(-2px);
}

.help-category-icon {
  font-size: 1.5rem;
  margin-right: 10px;
}

/* 설명 내용 스타일 */
.help-category-content {
  display: none;
  animation: fade-in 0.3s ease;
}

.help-category-content h3 {
  color: var(--color-secondary);
  margin-bottom: 15px;
  font-size: 1.5rem;
}

.help-category-content ul {
  margin-bottom: 15px;
  padding-left: 20px;
}

.help-category-content ul li {
  margin-bottom: 10px;
  line-height: 1.5;
  padding-left: 10px;
  text-indent: -5px;
}

.help-category-content .sub-list {
  margin-top: 8px;
  margin-left: 20px;
  padding-left: 15px;
}

.setting-note {
  font-size: 0.9rem;
  padding: 10px;
  background-color: rgba(255, 255, 255, 0.05);
  border-radius: 5px;
  margin-top: 10px;
}

.instruction-tip {
  padding: 15px;
  background-color: rgba(255, 0, 255, 0.1);
  border-radius: 8px;
  margin-top: 20px;
}

.instruction-tip p {
  margin: 0;
}

/* 크레딧 스타일 */
.credit-list {
  margin-bottom: 20px;
}

.credit-item {
  display: flex;
  margin-bottom: 15px;
  padding-bottom: 15px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.credit-role {
  flex: 0 0 100px;
  font-weight: bold;
  color: var(--color-primary);
}

.credit-name {
  flex: 1;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(-30px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 반응형 스타일 */
@media (max-width: 768px) {
  .help-modal-content, .credits-content {
    width: 95%;
    margin: 3vh auto;
  }
  
  .help-category-buttons {
    grid-template-columns: 1fr 1fr;
  }
  
  .main-menu {
    width: 80%;
    left: -80%;
  }
}

/* Main content styles */
main {
  padding-top: 60px; /* Adjusted for fixed header */
}

.container {
  max-width: 1200px;
  margin: 0 auto;
}

/* Footer styles */
footer {
  background-color: var(--color-darker);
  padding: 20px;
  text-align: center;
  color: var(--color-text-muted);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  width: 100%;
}

/* ---- css/modules/preloader.css ---- */
/* Preloader animation */
.preloader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--color-darker);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  transition: opacity 0.5s ease;
}

.horse-container {
  width: 200px;
  height: 100px;
  position: relative;
  margin-bottom: 30px;
}

.horse-silhouette {
  width: 100%;
  height: 100%;
  background: url('/images/track-banner.jpg') center center;
  background-size: cover;
  clip-path: polygon(
    17% 34%, 22% 26%, 28% 25%, 33% 18%, 36% 15%, 
    41% 12%, 47% 9%, 53% 7%, 60% 7%, 65% 9%, 
    71% 15%, 74% 21%, 80% 25%, 86% 35%, 89% 45%, 
    84% 45%, 79% 42%, 73% 42%, 63% 45%, 60% 55%, 
    55% 60%, 51% 57%, 47% 60%, 43% 65%, 38% 65%, 
    31% 60%, 27% 56%, 25% 50%, 17% 48%, 13% 42%
  );
  animation: gallop 0.8s infinite alternate;
}

.loading-text {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 15px;
  display: flex;
}

.loading-text span {
  display: inline-block;
  animation: loading-pulse 1.2s infinite alternate;
}

.loading-text span:nth-child(2) {
  animation-delay: 0.1s;
}
.loading-text span:nth-child(3) {
  animation-delay: 0.2s;
}
.loading-text span:nth-child(4) {
  animation-delay: 0.3s;
}
.loading-text span:nth-child(5) {
  animation-delay: 0.4s;
}
.loading-text span:nth-child(6) {
  animation-delay: 0.5s;
}
.loading-text span:nth-child(7) {
  animation-delay: 0.6s;
}

.loading-bar {
  width: 250px;
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  overflow: hidden;
}

.loading-progress {
  height: 100%;
  background: linear-gradient(90deg, var(--color-primary), var(--color-secondary));
  border-radius: 10px;
  width: 0;
  animation: progress 2s forwards ease-in-out;
  transition: width 0.5s ease;
}

/* ---- css/modules/hero.css ---- */
/* Hero section */
.hero {
  position: relative;
  height: 80vh;
  background: radial-gradient(ellipse at 70% 25%, #273e47 0%, #12191f 45%, #070a10 100%);
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  overflow: hidden;
  transition: display 0.5s ease;
}

.hero-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: repeating-linear-gradient(
    to bottom,
    transparent,
    transparent 1px,
    rgba(0, 0, 0, 0.1) 2px,
    rgba(0, 0, 0, 0.1) 3px
  );
}

.hero-content {
  max-width: 800px;
  padding: 0 20px;
  z-index: 1;
  position: relative;
  transform: perspective(800px) rotateX(10deg);
  transform-style: preserve-3d;
}

.hero h1 {
  font-size: 4.5rem;
  font-weight: 900;
  margin-bottom: 20px;
  line-height: 1.1;
  color: white;
  position: relative;
  text-shadow: 
    0 0 5px var(--color-primary),
    0 0 10px var(--color-primary),
    0 0 20px rgba(255, 0, 255, 0.5);
  animation: hero-glow 3s infinite alternate;
  letter-spacing: -1px;
}

.glitch-text {
  position: relative;
  animation: glitch-skew 1s infinite alternate-reverse;
}

.glitch-text::before,
.glitch-text::after {
  content: attr(data-text);
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.glitch-text::before {
  left: 2px;
  text-shadow: -2px 0 var(--color-secondary);
  clip: rect(44px, 450px, 56px, 0);
  animation: glitch-anim-1 5s infinite linear alternate-reverse;
}

.glitch-text::after {
  left: -2px;
  text-shadow: -2px 0 var(--color-primary);
  clip: rect(24px, 450px, 100px, 0);
  animation: glitch-anim-2 3s infinite linear alternate-reverse;
}

.hero-description {
  white-space: pre-line;
  font-size: 1.2rem;
  margin-bottom: 40px;
  opacity: 0.9;
}

/* ---- css/modules/buttons.css ---- */
/* Buttons */
.btn-primary {
  display: inline-block;
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  color: white;
  font-size: 1.2rem;
  font-weight: bold;
  padding: 12px 36px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  box-shadow: 0 0 15px rgba(255, 0, 255, 0.5);
  transition: transform 0.3s, box-shadow 0.3s;
  z-index: 9500; /* 높은 z-index로 버튼이 항상 최상위에 표시되도록 함 */
  
  /* Cross-browser consistency */
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  -webkit-border-radius: 5px;
  -moz-border-radius: 5px;
  -webkit-box-shadow: 0 0 15px rgba(255, 0, 255, 0.5);
  -moz-box-shadow: 0 0 15px rgba(255, 0, 255, 0.5);
  -webkit-transition: transform 0.3s, box-shadow 0.3s;
  -moz-transition: transform 0.3s, box-shadow 0.3s;
}

.btn-primary:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 0 25px rgba(255, 0, 255, 0.7);
}

.btn-primary:active {
  transform: translateY(1px);
}

.btn-primary::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.3),
    transparent
  );
  transition: left 0.7s;
}

.btn-primary:hover::before {
  left: 100%;
}

.pulse-effect {
  animation: pulse 2s infinite;
}

.btn-full {
  width: 100%;
}

.shuffle-btn {
  background-color: rgba(0, 0, 0, 0.2);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 5px;
  padding: 5px 10px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.3s;
}

.shuffle-btn:hover {
  background-color: rgba(255, 0, 255, 0.3);
  border-color: rgba(255, 0, 255, 0.5);
}

.recharge-button {
  background-color: rgba(76, 175, 80, 0.3);
  color: white;
  border: 1px solid rgba(76, 175, 80, 0.6);
  cursor: pointer;
  animation: green-pulse 2s infinite;
  transition: all 0.3s;
  margin-left: 10px;
  display: inline-block;
}

.recharge-button:hover {
  background-color: rgba(76, 175, 80, 0.5);
  transform: scale(1.05);
}

.bet-delete-btn {
  background-color: rgba(255, 59, 59, 0.8);
  color: white;
  border: none;
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 12px;
  cursor: pointer;
  animation: red-pulse 2s infinite;
  transition: all 0.3s;
}

.bet-delete-btn:hover {
  background-color: rgb(255, 0, 0);
  transform: scale(1.05);
}

/* ---- css/modules/features.css ---- */
/* Features Section */
.features {
  padding: 80px 20px;
  background-color: var(--color-dark);
  position: relative;
  overflow: hidden;
}

.features::before {
  content: "";
  position: absolute;
  top: -50px;
  left: 0;
  right: 0;
  height: 100px;
  background: linear-gradient(to bottom, transparent, var(--color-dark));
  z-index: 1;
}

.feature-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 30px;
  max-width: 1200px;
  margin: 0 auto;
}

.feature-card {
  background: rgba(255, 255, 255, 0.03);
  padding: 30px;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(5px);
  border: 1px solid rgba(255, 255, 255, 0.05);
  transform: translateY(0);
  transition: all 0.4s ease;
  position: relative;
  overflow: hidden;
}

.feature-card:hover {
  transform: translateY(-10px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
  border-color: rgba(255, 0, 255, 0.2);
}

.feature-card::after {
  content: "";
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(
    to bottom right,
    rgba(255, 255, 255, 0),
    rgba(255, 255, 255, 0.05),
    rgba(255, 255, 255, 0)
  );
  transform: rotate(30deg);
  transition: transform 0.5s;
  pointer-events: none;
}

.feature-card:hover::after {
  transform: rotate(30deg) translate(10%, 10%);
}

.feature-icon {
  font-size: 3rem;
  margin-bottom: 20px;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

.feature-card h3 {
  font-size: 1.5rem;
  margin-bottom: 15px;
  color: var(--color-secondary);
  position: relative;
  display: inline-block;
}

.feature-card h3::after {
  content: "";
  position: absolute;
  bottom: -5px;
  left: 0;
  width: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--color-primary), var(--color-secondary));
  transition: width 0.3s;
}

.feature-card:hover h3::after {
  width: 100%;
}

.feature-card p {
  color: var(--color-text-muted);
  line-height: 1.7;
  font-size: 0.95rem;
}

/* ---- css/modules/horse-names.css ---- */
/* Horse name customization */
.horse-names-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 5px 0;
}

.horse-names-container {
  max-height: 200px;
  overflow-y: auto;
  margin-top: 5px;
  padding-right: 10px;
}

.horse-names-container::-webkit-scrollbar {
  width: 6px;
}

.horse-names-container::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 10px;
}

.horse-names-container::-webkit-scrollbar-thumb {
  background: rgba(255, 0, 255, 0.5);
  border-radius: 10px;
}

.horse-name-input {
  display: flex;
  align-items: center;
  margin-bottom: 8px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 5px;
  padding: 5px 10px;
  transition: all 0.3s;
}

.horse-name-input:hover {
  background: rgba(255, 255, 255, 0.1);
}

.horse-name-input .horse-number {
  font-size: 1.2rem;
  margin-right: 10px;
  min-width: 24px;
}

.horse-name-input input {
  flex: 1;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  color: white;
  padding: 5px 8px;
  font-size: 0.9rem;
  position: relative;
}

.horse-name-input input:focus {
  outline: none;
  border-color: rgba(255, 0, 255, 0.5);
  box-shadow: 0 0 5px rgba(255, 0, 255, 0.3);
}

.horse-name-input input::placeholder {
  color: rgba(255, 255, 255, 0.6);
  opacity: 1;
}

/* ---- css/modules/race-track.css ---- */
/* Race Track Section */
.race-track {
  display: none;
  background-color: var(--color-dark);
  padding: 20px;
  border-radius: 0;
  margin: 0;
  width: 100%;
  min-height: calc(100vh - 60px); /* Full height minus header */
  position: relative;
}

.timer {
  text-align: center;
  font-size: 2.5rem;
  font-weight: bold;
  padding: 12px 0;
  margin-bottom: 20px;
  background: linear-gradient(90deg, var(--color-dark), var(--color-darker), var(--color-dark));
  border-radius: 10px;
  box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.6), 0 5px 15px rgba(0, 0, 0, 0.3);
  color: var(--color-primary);
  text-shadow: 0 0 8px rgba(255, 0, 255, 0.8);
  border: 1px solid rgba(255, 0, 255, 0.2);
  position: relative;
  overflow: hidden;
  font-family: 'Courier New', monospace;
  letter-spacing: 1px;
}

.timer::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 50%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
  animation: timer-shine 3s infinite;
}

.track {
  background-color: #1a1a1a;
  min-height: calc(100vh - 160px);
  border-radius: 10px;
  padding: 20px;
  position: relative;
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  overflow: hidden;
  background-image: linear-gradient(0deg, rgba(10, 10, 10, 0.8), rgba(30, 30, 30, 0.3));
}

/* Track condition styles */
.track-condition {
  position: absolute;
  z-index: 5;
  opacity: 0.45;
  border-radius: 8px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.6);
  background-size: 20px 20px;
  background-repeat: repeat;
  border: 2px solid rgba(255, 255, 255, 0.3);
  transform: perspective(300px) rotateX(10deg);
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Special styling for acceleration condition */
.track-condition[style*="FFD700"] {
  opacity: 0.65;
  border: 2px solid rgba(255, 215, 0, 0.7);
  box-shadow: 0 0 15px rgba(255, 215, 0, 0.8);
  animation: pulse-gold 1.5s infinite alternate;
  z-index: 4;
}

/* Speed boost effect for horses */
.horse.speed-boost {
  filter: brightness(1.5) drop-shadow(0 0 5px gold);
  animation: zoom-boost 0.5s ease-in;
}

.obstacle-emoji {
  font-size: 20px;
  position: absolute;
  z-index: 6;
  filter: drop-shadow(0 0 3px rgba(0,0,0,0.7));
  animation: float 1.5s infinite alternate ease-in-out;
}

.track-condition-label {
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  background-color: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 2px 6px;
  border-radius: 8px;
  font-size: 10px;
  font-weight: bold;
  white-space: nowrap;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
  z-index: 7;
}

.lane {
  height: 50px;
  background: linear-gradient(90deg, rgba(20, 20, 20, 0.9), rgba(40, 40, 40, 0.9));
  margin-bottom: 15px;
  border-radius: 5px;
  position: relative;
  overflow: visible;
  contain: layout style;
  box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.lane::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: inherit;
  pointer-events: none;
  background: repeating-linear-gradient(
    90deg,
    transparent,
    transparent 20px,
    rgba(255, 255, 255, 0.1) 20px,
    rgba(255, 255, 255, 0.1) 40px
  );
  opacity: 0.5;
}

.lane:nth-child(odd) {
  background: linear-gradient(90deg, rgba(15, 15, 15, 0.9), rgba(35, 35, 35, 0.9));
}

.horse-motion {
  position: absolute;
  left: 0;
  top: 5px;
  z-index: 10;
  transform: translate3d(0, 0, 0);
  transition: transform 100ms linear;
}

.horse {
  position: absolute;
  left: 0;
  top: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 20px;
  z-index: 10;
  box-shadow: 0 0 15px rgba(0, 0, 0, 0.5);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(0, 0, 0, 0.3));
  border: 2px solid rgba(255, 255, 255, 0.2);
  position: relative;
}

.lap-indicator {
  position: absolute;
  top: 0;
  left: 50%;
  background-color: rgba(255, 0, 255, 0.6);
  color: white;
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 10px;
  font-weight: bold;
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.5), 0 0 10px rgba(0, 0, 0, 0.3);
  pointer-events: none;
  z-index: 90; /* 낮은 z-index 값으로 변경 */
  font-family: 'Consolas', monospace;
  border: 1px solid rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -100%);
  margin-top: -5px;
  visibility: visible !important;
  overflow: visible !important;
}

.horse-name {
  position: absolute;
  left: 10px;
  top: 15px;
  font-size: 14px;
  font-weight: bold;
  color: rgba(255, 255, 255, 0.8);
  z-index: 1;
  pointer-events: none;
  text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.7);
}

.finish-line {
  position: absolute;
  right: 10px;
  top: 0;
  height: 100%;
  width: 2px;
  background-color: var(--color-primary);
  z-index: 1;
  box-shadow: 0 0 10px var(--color-primary), 0 0 20px var(--color-primary);
}

.finish-line::before, 
.finish-line::after {
  content: "";
  position: absolute;
  width: 10px;
  height: 10px;
  background-color: var(--color-primary);
  border-radius: 50%;
  left: -4px;
  box-shadow: 0 0 5px var(--color-primary);
}

.finish-line::before {
  top: 0;
}

.finish-line::after {
  bottom: 0;
}

/* Finish line flash animation effect */
.finish-line.flash {
  animation: finish-line-flash 0.6s ease-in-out;
}

/* Horse finish animation */
.horse.finishing {
  animation: horse-finish 0.5s ease-in-out;
  filter: brightness(1.5) drop-shadow(0 0 10px white);
}

.race-results {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(15, 15, 18, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 10px;
  padding: 25px;
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.7), 0 0 15px rgba(255, 0, 255, 0.3);
  z-index: 10000;
  text-align: center;
  width: 85%;
  max-width: 600px;
  max-height: 85vh; /* Increased max-height */
  overflow-y: auto; /* Changed from hidden to auto to enable scrolling */
  border: 1px solid rgba(255, 0, 255, 0.2);
  display: none;
  touch-action: pan-y pinch-zoom; /* Explicitly allow vertical scrolling and pinch zoom */
  -webkit-overflow-scrolling: touch; /* Smooth native-like scrolling on iOS */
  user-select: text; /* Enable text selection */
  scrollbar-width: none; /* Hide scrollbar for Firefox */
  -ms-overflow-style: none; /* Hide scrollbar for IE and Edge */
  overscroll-behavior: contain; /* Prevent scroll chaining */
  pointer-events: auto; /* Ensure touch events are captured */
}

/* Hide scrollbar for Webkit browsers */
.race-results::-webkit-scrollbar {
  width: 0;
  display: none;
}

.race-results h2 {
  color: var(--color-primary);
  font-size: 2rem;
  margin-bottom: 20px;
  text-shadow: var(--glow-primary);
}

/* Style the new race button to be more visible */
#newRaceBtn {
  margin-top: 20px;
  margin-bottom: 15px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  box-shadow: 0 0 15px rgba(255, 0, 255, 0.5);
  position: relative;
  z-index: 10001;
}

.results-list {
  margin-bottom: 25px;
  max-height: none; /* Remove height limit to prevent inner scrolling */
  overflow-y: visible; /* Change to visible to prevent inner scrolling */
  padding: 0 10px 0 2px; /* Adjusted padding for better touch area */
  touch-action: pan-y; /* Explicitly allow vertical scrolling */
  overscroll-behavior: contain; /* Prevent scroll chaining */
  position: relative; /* Ensure proper stacking context */
}

.all-results-container {
  /* Container for all results (betting + race) to maintain a single scroll area */
  width: 100%;
  overflow-y: visible;
}

/* Hide scrollbar for Webkit browsers but maintain functionality */
.results-list::-webkit-scrollbar {
  width: 0;
  display: none;
}

/* Alternatively, if we want a fancy neon scrollbar instead of hiding it:
.results-list::-webkit-scrollbar {
  width: 6px;
  background: transparent;
}

.results-list::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 10px;
  box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
}

.results-list::-webkit-scrollbar-thumb {
  background: var(--color-primary);
  border-radius: 10px;
  box-shadow: 0 0 8px var(--color-primary), 0 0 15px var(--color-primary);
  animation: pulse-gold 1.5s infinite alternate;
}
*/

.results-list div {
  padding: 8px 10px;
  margin-bottom: 8px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 5px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
  -webkit-box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
  transition: all 0.3s;
  -webkit-transition: all 0.3s;
  border-left: 3px solid transparent;
  /* Improve touch events on Android */
  touch-action: auto; /* Allow all touch actions on result items */
  -webkit-tap-highlight-color: transparent;
  user-select: text; /* Enable text selection */
  cursor: default; /* Default cursor for better touch indication */
  pointer-events: auto; /* Ensure touch events work */
}

.results-list div:hover {
  transform: perspective(500px) rotateX(0);
  background: rgba(255, 255, 255, 0.1);
}

/* Medal classes for race results */
.gold-medal {
  border-left-color: gold !important;
}

.silver-medal {
  border-left-color: silver !important;
}

.bronze-medal {
  border-left-color: #cd7f32 !important;
}

/* Remove border from other elements */
.betting-results-header, 
.betting-results-container, 
.bet-result, 
.bet-total, 
.balance-display {
  border-left-color: transparent !important;
}

/* Race results header */
.race-results-header {
  font-size: 16px;
  font-weight: bold;
  margin-bottom: 10px;
  color: white;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  padding-bottom: 6px;
  width: 100%;
  text-align: center;
  margin-top: 15px;
}

.betting-results-header {
  font-size: 16px;
  font-weight: bold;
  margin-bottom: 10px;
  color: white;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  padding-bottom: 6px;
  width: 100%;
  text-align: center;
}

.betting-results-container {
  overflow: visible;
  max-height: none;
  margin-bottom: 15px;
}

/* Track options */
.track-options, .performance-options {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
}

.track-option, .performance-option {
  flex: 1;
  background-color: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 10px;
  text-align: center;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.3s;
  margin: 0 5px;
  color: var(--color-text-muted);
}

.track-option:first-child, .performance-option:first-child {
  margin-left: 0;
}

.track-option:last-child, .performance-option:last-child {
  margin-right: 0;
}

.track-option:hover, .performance-option:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.track-option.active, .performance-option.active {
  background-color: rgba(var(--color-primary-rgb), 0.2);
  color: var(--color-primary);
  border-color: var(--color-primary);
  box-shadow: 0 0 10px rgba(255, 0, 255, 0.3);
}

/* FPS counter styles */
.fps-counter {
  position: fixed;
  top: 70px;
  left: 10px;
  /* Stay below the fixed header in every screen, including iOS safe areas. */
  top: calc(70px + env(safe-area-inset-top, 0px));
  left: calc(10px + env(safe-area-inset-left, 0px));
  right: auto;
  bottom: auto;
  width: 88px;
  background-color: rgba(0, 0, 0, 0.7);
  color: #4CAF50;
  padding: 4px 8px;
  border: 1px solid rgba(76, 175, 80, 0.3);
  border-radius: 4px;
  font-family: monospace;
  font-size: 14px;
  line-height: 20px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  z-index: 9999; /* Increased z-index to appear above all content */
  display: block; /* Set to block by default to be visible */
  pointer-events: none; /* Allows clicks to pass through */
  text-shadow: 1px 1px 2px black; /* Better visibility */
  font-weight: bold;
}

/* Performance styles */
.device-performance {
  margin: 10px 0;
  font-size: 14px;
  color: var(--color-text-muted);
  font-style: italic;
}

.fps-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

/* Switch styling */
.switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(80, 80, 80, 0.5);
  transition: .3s;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s;
}

input:checked + .slider {
  background-color: var(--color-primary);
}

input:checked + .slider:before {
  transform: translateX(22px);
}

.slider.round {
  border-radius: 24px;
}

.slider.round:before {
  border-radius: 50%;
}

/* Event styles */
.event-container {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 100;
  width: 320px;
  max-width: 90%;
  opacity: 1;
}

.ranking-container {
  position: fixed;
  top: 60px;
  right: 20px;
  z-index: 100;
  background-color: rgba(0, 0, 0, 0.6);
  border-radius: 8px;
  padding: 10px 15px;
  width: auto;
  min-width: 200px;
  max-width: 90%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  animation: ranking-fade-in 0.4s ease-out;
}

.ranking-title {
  font-size: 16px;
  font-weight: bold;
  margin-bottom: 10px;
  color: white;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  padding-bottom: 6px;
  width: 100%;
  text-align: center;
  text-shadow: 0 0 10px rgba(255, 0, 255, 0.5);
}

.ranking-item {
  display: flex;
  align-items: center;
  margin-bottom: 7px;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.9);
  width: 100%;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background-color 0.2s;
}

.ranking-item:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.ranking-position {
  width: 22px;
  margin-right: 8px;
  font-weight: bold;
}

.ranking-time {
  margin-left: auto;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.9);
  font-family: monospace;
  background-color: rgba(0, 0, 0, 0.2);
  padding: 2px 6px;
  border-radius: 4px;
}

.lap-badge {
  margin-left: 8px;
  font-size: 11px;
  color: white;
  background-color: rgba(255, 0, 255, 0.3);
  padding: 1px 5px;
  border-radius: 10px;
  font-weight: bold;
  border: 1px solid rgba(255, 0, 255, 0.5);
  box-shadow: 0 0 5px rgba(255, 0, 255, 0.3);
}

.ranking-icon {
  margin-right: 8px;
  font-size: 1.2em;
}

@media (max-width: 768px) {
  .ranking-container {
    display: none; /* Hide ranking on mobile screens to save space */
  }
}

.event-message {
  background-color: rgba(0, 0, 0, 0.6);
  color: rgba(255, 255, 255, 0.9);
  padding: 8px 12px;
  margin-bottom: 8px;
  border-radius: 6px;
  border-left: 2px solid var(--color-primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  animation: event-fade-in 0.3s ease-out;
  font-size: 1em;
  font-weight: 500;
  backdrop-filter: blur(3px);
}

.event-message:nth-child(2) {
  opacity: 0.9;
  transform: scale(0.98);
}

.event-message:nth-child(3) {
  opacity: 0.8;
  transform: scale(0.95);
}

/* Horse status indicators */
.status-container {
  position: absolute;
  top: -15px;
  left: 50px;
  width: calc(100% - 70px);
  z-index: 1;
  display: flex;
  align-items: center;
}

.stamina-bar {
  flex: 1;
  height: 5px;
  background-color: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
  overflow: hidden;
  margin-right: 5px;
}

.stamina-progress {
  height: 100%;
  background-color: #4CAF50;
  transform-origin: left center;
  transition: transform 100ms linear;
  width: 100%;
}

.stamina-text {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.8);
  text-shadow: 0 0 3px rgba(0, 0, 0, 0.8);
  min-width: 30px;
  text-align: center;
}

/* Horse state styles */
.horse.resting {
  animation: resting 2s infinite;
  opacity: 0.7;
}

.horse.lightning-immune {
  box-shadow: 0 0 15px #FFEB3B, 0 0 25px #FFEB3B;
  animation: immunity 2s infinite;
}

/* ---- css/modules/modal.css ---- */
/* Modal styles */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2000;
  background-color: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  -webkit-overflow-scrolling: touch;
}

.modal-content {
  background-color: var(--color-dark);
  margin: 5vh auto;
  padding: 20px;
  border-radius: 10px;
  max-width: 500px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 0, 255, 0.5) rgba(0, 0, 0, 0.2);
  box-shadow: 0 0 30px rgba(255, 0, 255, 0.3);
  -webkit-box-shadow: 0 0 30px rgba(255, 0, 255, 0.3);
  transform: perspective(1000px) rotateX(0deg);
  -webkit-transform: perspective(1000px) rotateX(0deg);
  transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  -webkit-transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  border: 1px solid rgba(255, 0, 255, 0.2);
  animation: modal-in 0.5s forwards;
  -webkit-animation: modal-in 0.5s forwards;
}

/* Scrollbars for modal content are now hidden globally in style.css */

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 15px;
  margin-bottom: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-header h2 {
  color: var(--color-primary);
  margin: 0;
  font-size: 1.8rem;
  text-shadow: var(--glow-primary);
}

.close-modal, .close-info-modal {
  font-size: 28px;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all 0.3s;
}

.close-modal:hover, .close-info-modal:hover {
  color: var(--color-primary);
  transform: rotate(90deg);
}

.settings-form, .info-content {
  padding: 10px 0;
}

/* Info modal styles */
.info-buttons {
  display: flex;
  justify-content: space-between;
  margin-bottom: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 10px;
}

.info-detail-btn {
  padding: 8px 15px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 5px;
  color: var(--color-text);
  cursor: pointer;
  transition: all 0.3s;
}

.info-detail-btn.active, .info-detail-btn:hover {
  background: rgba(255, 0, 255, 0.1);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.info-tab-content {
  display: none;
}

.info-tab-content.active {
  display: block;
  animation: fade-in 0.3s ease-in-out;
}

.info-section {
  margin-bottom: 15px;
}

.info-section h3 {
  color: var(--color-secondary);
  margin-bottom: 15px;
}

.info-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
}

.info-detail-btn {
  padding: 8px 15px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 5px;
  color: var(--color-text);
  cursor: pointer;
  transition: all 0.3s;
}

.info-detail-btn:hover {
  background: rgba(255, 0, 255, 0.1);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.info-detail-content {
  display: none;
  animation: slide-in 0.3s ease-in-out;
}

.back-btn {
  padding: 5px 10px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 5px;
  color: var(--color-text-muted);
  cursor: pointer;
  margin-bottom: 15px;
  transition: all 0.3s;
}

.back-btn:hover {
  background: rgba(255, 0, 255, 0.1);
  color: var(--color-text);
}

@keyframes slide-in {
  from { transform: translateX(30px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.form-group {
  margin-bottom: 25px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  color: var(--color-text);
  font-size: 1.1rem;
}

.range-slider-container {
  display: flex;
  align-items: center;
}

/* Weather selector styles */
.weather-selector {
  width: 100%;
}

.weather-select {
  width: 100%;
  padding: 10px;
  background-color: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 5px;
  color: white;
  font-size: 1rem;
  appearance: none;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="12" height="6" viewBox="0 0 12 6"><path fill="white" d="M0 0l6 6 6-6z"/></svg>');
  background-repeat: no-repeat;
  background-position: right 10px center;
  transition: all 0.3s;
}

.weather-select:hover {
  border-color: var(--color-primary);
}

.weather-select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 8px rgba(255, 0, 255, 0.4);
}

.weather-select option {
  background-color: var(--color-dark);
  color: white;
  padding: 10px;
}

input[type="range"] {
  flex: 1;
  height: 5px;
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 5px;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%; 
  background: var(--color-primary);
  box-shadow: 0 0 10px rgba(255, 0, 255, 0.7);
  cursor: pointer;
  transition: all 0.3s;
}

input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border: 0;
  border-radius: 50%;
  background: var(--color-primary);
  box-shadow: 0 0 10px rgba(255, 0, 255, 0.7);
  cursor: pointer;
  transition: all 0.3s;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.1);
  box-shadow: 0 0 15px rgba(255, 0, 255, 0.9);
}

.range-value {
  min-width: 60px;
  text-align: center;
  margin-left: 15px;
  background-color: rgba(255, 255, 255, 0.05);
  padding: 5px 10px;
  border-radius: 5px;
  font-weight: bold;
}

/* ---- css/modules/betting.css ---- */
/* Betting UI styles */
.betting-ui {
  position: fixed;
  top: 120px;
  left: 20px;
  z-index: 100;
  background-color: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
  border-radius: 10px;
  padding: 15px;
  width: 280px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 0, 255, 0.3);
  color: white;
  max-height: 80vh;
  overflow-y: auto;
}

.betting-title {
  font-size: 18px;
  font-weight: bold;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--color-primary);
  text-shadow: 0 0 5px rgba(255, 0, 255, 0.5);
}

.balance,
.balance-display {
  background-color: rgba(255, 255, 255, 0.1);
  padding: 8px 12px;
  border-radius: 5px;
  margin-bottom: 15px;
  font-weight: bold;
  font-size: 14px;
}

.bet-type-tabs {
  display: flex;
  margin-bottom: 15px;
  border-radius: 5px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Bet item styles */
.bet-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: rgba(255, 255, 255, 0.05);
  padding: 10px 15px;
  margin-bottom: 12px;
  border-radius: 5px;
  position: relative;
  max-width: 100%;
  flex-wrap: wrap;
}

.bet-item-info {
  flex: 1;
  font-weight: 500;
  margin-right: 10px;
}

.bet-item-amount {
  font-weight: bold;
  margin-right: 10px;
}

.bet-tab {
  flex: 1;
  text-align: center;
  padding: 8px 0;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.3s;
  background-color: rgba(0, 0, 0, 0.3);
}

.bet-tab:hover {
  background-color: rgba(255, 0, 255, 0.2);
}

.bet-tab.active {
  background-color: rgba(255, 0, 255, 0.3);
  color: white;
  font-weight: bold;
  box-shadow: inset 0 0 10px rgba(255, 0, 255, 0.5);
}

/* Betting section styles */
.betting-section {
  margin-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 20px;
}

.betting-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.bet-type-selector {
  margin-bottom: 15px;
}

.bet-type-label {
  margin-bottom: 5px;
  font-size: 14px;
  color: var(--color-text-muted);
}

.bet-tabs {
  display: flex;
  background-color: rgba(0, 0, 0, 0.2);
  border-radius: 5px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.bet-description {
  font-size: 13px;
  color: var(--color-text-muted);
  margin-bottom: 15px;
  padding: 5px 10px;
  background-color: rgba(0, 0, 0, 0.2);
  border-radius: 5px;
  text-align: center;
}

.bet-content {
  background-color: rgba(0, 0, 0, 0.2);
  border-radius: 5px;
  padding: 15px;
  margin-bottom: 15px;
}

.selection-container {
  margin-bottom: 15px;
}

.selection-container label {
  display: block;
  margin-bottom: 5px;
  font-size: 14px;
}

.bet-horse-select {
  width: 100%;
  padding: 8px 10px;
  background-color: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 5px;
  color: white;
  margin-bottom: 10px;
  appearance: none;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="12" height="6" viewBox="0 0 12 6"><path fill="white" d="M0 0l6 6 6-6z"/></svg>');
  background-repeat: no-repeat;
  background-position: right 10px center;
}

.double-selection {
  margin-bottom: 10px;
}

.odds-display-container {
  margin: 15px 0;
  font-size: 16px;
  font-weight: bold;
  text-align: center;
  padding: 8px;
  background-color: rgba(0, 0, 0, 0.2);
  border-radius: 5px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.bet-amount-container {
  margin-bottom: 10px;
}

.bet-amount {
  width: 100%;
  padding: 8px 10px;
  background-color: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 5px;
  color: white;
  font-size: 16px;
}

.quick-amount-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 15px;
}

.quick-amount-btn {
  flex: 1;
  min-width: calc(50% - 5px);
  padding: 5px 0;
  background-color: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 5px;
  color: white;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.3s;
}

.quick-amount-btn:hover {
  background-color: rgba(255, 0, 255, 0.3);
  border-color: rgba(255, 0, 255, 0.5);
}

.place-bet-button {
  width: 100%;
  padding: 10px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  color: white;
  border: none;
  border-radius: 5px;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 0 10px rgba(255, 0, 255, 0.3);
  transition: all 0.3s;
}

.place-bet-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 15px rgba(255, 0, 255, 0.5);
}

.place-bet-button:active {
  transform: translateY(1px);
}

.current-bets-container {
  margin-top: 15px;
}

.current-bets-header {
  font-weight: bold;
  margin-bottom: 10px;
  padding-bottom: 5px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.current-bets-list {
  max-height: 200px;
  overflow-y: auto;
}

.hidden {
  display: none;
}

/* ---- css/modules/instructions.css ---- */
/* Game instructions styles */
.game-instructions {
  background-color: var(--color-darker);
  padding: 60px 20px;
  position: relative;
}

.game-instructions::before {
  content: "";
  position: absolute;
  top: -50px;
  left: 0;
  right: 0;
  height: 50px;
  background: linear-gradient(to bottom, transparent, var(--color-darker));
  z-index: 1;
}

/* Game help modal and language setting modal */
.game-help-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.85);
  z-index: 2000;
  overflow-y: auto;
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

.section-title {
  text-align: center;
  font-size: 2.5rem;
  margin-bottom: 40px;
  color: var(--color-primary);
  text-shadow: var(--glow-primary);
  position: relative;
}

.section-title::after {
  content: "";
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 80px;
  height: 3px;
  background: linear-gradient(90deg, var(--color-primary), var(--color-secondary));
}

.instruction-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 30px;
  margin-bottom: 40px;
}

.instruction-card {
  background: rgba(255, 255, 255, 0.03);
  border-radius: 10px;
  padding: 25px;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.05);
  transition: transform 0.3s, box-shadow 0.3s;
}

.instruction-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 15px 30px rgba(0, 0, 0, 0.3);
  border-color: rgba(255, 0, 255, 0.2);
}

.instruction-card h3 {
  font-size: 1.3rem;
  margin-bottom: 15px;
  color: var(--color-secondary);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 10px;
}

.instruction-card ul {
  list-style-type: none;
  padding: 0;
}

.instruction-card li {
  margin-bottom: 8px;
  padding-left: 20px;
  position: relative;
  line-height: 1.5;
  color: var(--color-text-muted);
}

.instruction-card li::before {
  content: "•";
  color: var(--color-primary);
  position: absolute;
  left: 0;
  font-weight: bold;
}

.instruction-card strong {
  color: white;
}

.instruction-tip {
  background: rgba(0, 255, 255, 0.05);
  border-left: 3px solid var(--color-secondary);
  padding: 15px 20px;
  border-radius: 5px;
  margin: 40px auto;
  max-width: 800px;
  text-align: center;
}

.instruction-tip p {
  margin: 0;
  color: var(--color-text-muted);
  line-height: 1.6;
}

@media (max-width: 768px) {
  .section-title {
    font-size: 2rem;
  }
  
  .instruction-grid {
    grid-template-columns: 1fr;
  }
  
  .instruction-card {
    padding: 20px;
  }
}
/* The help hub introduces every game; race-only details stay in their own group. */
#help-categories { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
#game-help-modal .help-overview, #game-help-modal .help-group-title, #game-help-modal .help-more { grid-column: 1 / -1; }
#game-help-modal .help-overview p { color: #b7ccc5; font-size: 13px; line-height: 1.8; margin: 0 0 10px; word-break: keep-all; overflow-wrap: anywhere; }
#game-help-modal .help-overview .help-intro { color: #edf2e5; font-size: 16px; font-weight: 600; }
#game-help-modal .help-group-title { color: #b5bea8; font-size: 12px; font-weight: 600; margin: 8px 0 0; }
#game-help-modal .help-game-button { align-items: flex-start; gap: 12px; padding: 18px 14px; min-height: 102px; text-align: left; }
#game-help-modal .help-game-number { color: #f1c398; font: 12px/1.9 ui-monospace,monospace; }
#game-help-modal .help-game-copy { display: grid; gap: 7px; flex: 1; min-width: 0; }
#game-help-modal .help-game-copy strong { color: #f0f3e9; font-size: 16px; line-height: 1.4; }
#game-help-modal .help-game-copy > span { color: #abc3ba; font-size: 12px; line-height: 1.6; }
#game-help-modal .help-game-arrow { color: #abc3ba; font-size: 18px; }
#game-help-modal .help-category-button { min-width: 0; white-space: normal; overflow-wrap: anywhere; word-break: keep-all; }
#game-help-modal .help-more { margin-top: 6px; border-top: 1px solid #42595b; }
#game-help-modal .help-more > summary { padding: 17px 0; cursor: pointer; min-height: 48px; color: #d3dfc9; font-size: 14px; }
#game-help-modal .help-advanced-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
#game-help-modal .help-advanced-grid .help-category-button { min-height: 54px; padding: 12px; text-align: left; font-size: 13px; }
#game-help-modal .help-category-content { color: #c3d3cd; line-height: 1.85; font-size: 14px; overflow-wrap: anywhere; word-break: keep-all; }
#game-help-modal .help-category-content h3 { color: #e4ecd8; font-size: 17px; margin: 26px 0 12px; padding-bottom: 8px; border-bottom: 1px solid #3d5559; }
#game-help-modal .help-category-content strong { color: #f4cd9d; }
#game-help-modal .help-category-content .help-lead { color: #d8e5df; line-height: 1.85; margin-bottom: 20px; }
#game-help-modal .help-steps { padding-left: 23px; margin-bottom: 20px; }
#game-help-modal .help-steps li { padding-left: 7px; margin-bottom: 14px; }
#game-help-modal .help-steps li::marker { color: #f4cd9d; font-weight: 700; }
#game-help-modal .help-callout { padding: 14px 16px; margin: 18px 0; background: #213d3b; border-left: 3px solid #a4bd7b; border-radius: 3px 10px 10px 3px; color: #d4e2d4; font-size: 13px; }
#game-help-modal .help-rule-table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 13px; line-height: 1.75; }
#game-help-modal .help-rule-table caption { text-align: left; color: #a7beb5; margin-bottom: 9px; font-size: 12px; }
#game-help-modal .help-rule-table th, #game-help-modal .help-rule-table td { text-align: left; vertical-align: top; padding: 12px; border: 1px solid #425c60; }
#game-help-modal .help-rule-table th:first-child { width: 34%; }
#game-help-modal .help-rule-table thead { background: #233c40; color: #e4ecd8; }
#game-help-modal .help-rule-table tbody th { color: #d1dfd6; font-weight: 500; }
#game-help-modal .help-question { border: 1px solid #425c60; border-radius: 10px; padding: 0 14px; margin-bottom: 10px; }
#game-help-modal .help-question summary { min-height: 48px; padding: 12px 0; cursor: pointer; color: #e0e9d6; }
#game-help-modal .help-question p { padding: 0 0 14px; margin: 0; font-size: 13px; }
#game-help-modal .instruction-tip { margin: 20px 0 0; padding: 12px 14px; text-align: left; background: #243a3a; border-left-color: #7b9f91; }
#game-help-modal .instruction-tip p { font-size: 12px; line-height: 1.8; }
@media (max-width: 520px) {
  #help-categories { grid-template-columns: minmax(0,1fr); gap: 10px; }
  #game-help-modal .help-game-button { min-height: 78px; padding: 13px; }
  #game-help-modal .help-rule-table th, #game-help-modal .help-rule-table td { padding: 10px 8px; }
  #game-help-modal .help-advanced-grid { grid-template-columns: minmax(0,1fr); }
}

/* All 20 games share one searchable rules directory; the content comes from
   each game's four-step, localized guide rather than a second summary. */
#game-help-modal .help-game-search { grid-column:1/-1; display:grid; gap:8px; margin:4px 0 7px; }
#game-help-modal .help-game-search-label { color:#e1e9df; font-weight:750; font-size:13px; }
#game-help-modal .help-game-search-input { width:100%; min-height:46px; padding:11px 14px; background:#f6f8f4; color:#1b342c; border:2px solid #96ac9f; border-radius:10px; font:inherit; font-size:14px; }
#game-help-modal .help-game-search-input:focus-visible { outline:3px solid #bcdda3; outline-offset:2px; }
#game-help-modal .help-game-empty { grid-column:1/-1; color:#cfddd4; padding:8px; }
#game-help-modal .help-game-directory-grid { grid-column:1/-1; display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; }
#game-help-modal .help-game-directory-grid[hidden],
#game-help-modal .help-game-empty[hidden],
#game-help-modal .help-category-button[hidden],
#game-help-modal .help-group-title[hidden] { display:none!important; }
#game-help-modal .help-game-directory-grid .help-game-button { min-height:122px; width:100%; align-items:flex-start; text-align:left; gap:10px; padding:13px; }
#game-help-modal .help-game-icon { flex:0 0 28px; font-size:20px; line-height:1.4; }
#game-help-modal .help-game-summary { color:#d9e1dc; font-size:12px; line-height:1.55; }
#game-help-modal .help-game-meta { color:#a7c5b8; font-size:11px; line-height:1.5; }
#game-help-modal .home-game-guide-steps { display:grid; gap:17px; padding-left:25px; margin:18px 0 26px; }
#game-help-modal .home-game-guide-step { margin:0; padding:0 0 10px 8px; }
#game-help-modal .home-game-guide-step h3 { margin:0 0 10px; padding:0 0 7px; font-size:16px; }
#game-help-modal .home-game-guide-step p { margin:0 0 9px; line-height:1.85; }
#game-help-modal .home-game-guide-play { display:inline-flex; align-items:center; justify-content:center; min-height:46px; padding:10px 17px; margin:5px 0 18px; border-radius:9px; border:1px solid #bfddad; color:#143d33; background:#d6edc1; font-size:13px; font-weight:800; text-decoration:none; }
#game-help-modal .home-game-guide-play:hover { background:#eef9db; }
@media(max-width:620px){
 #game-help-modal .help-game-directory-grid { grid-template-columns:minmax(0,1fr); }
 #game-help-modal .help-game-directory-grid .help-game-button { min-height:88px; }
}
/* The old tip applied dice/card tiebreak rules to unrelated games (e.g. chess).
   Each game now carries its own rule notes inside the shared guide. */
#game-help-modal .instruction-tip { display:none!important; }

/* ---- css/modules/weather.css ---- */
/* Weather Effects */
.weather-indicator {
  --weather-accent: #ffd56b;
  --weather-bg: rgba(18, 32, 40, 0.88);
  --weather-border: rgba(255, 213, 107, 0.42);
  position: fixed;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, var(--weather-bg), rgba(12, 22, 29, 0.92));
  border-radius: 999px;
  padding: 7px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 900;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(8px);
  border: 1px solid var(--weather-border);
  animation: weather-fade-in 0.5s ease-in-out;
}

.weather-indicator.weather-sunny {
  --weather-accent: #ffd86b;
  --weather-bg: rgba(44, 36, 18, 0.86);
  --weather-border: rgba(255, 216, 107, 0.52);
}

.weather-indicator.weather-rainy {
  --weather-accent: #7cc8ff;
  --weather-bg: rgba(18, 35, 52, 0.88);
  --weather-border: rgba(124, 200, 255, 0.5);
}

.weather-indicator.weather-windy {
  --weather-accent: #8ce8c4;
  --weather-bg: rgba(18, 42, 38, 0.88);
  --weather-border: rgba(140, 232, 196, 0.5);
}

.weather-indicator.weather-stormy {
  --weather-accent: #c5a3ff;
  --weather-bg: rgba(26, 22, 48, 0.9);
  --weather-border: rgba(197, 163, 255, 0.55);
}

.weather-indicator.weather-foggy {
  --weather-accent: #d4e4e2;
  --weather-bg: rgba(30, 42, 44, 0.88);
  --weather-border: rgba(212, 228, 226, 0.46);
}

.weather-icon {
  font-size: 26px;
  margin-right: 2px;
  animation: weather-icon-float 3s infinite alternate ease-in-out;
  filter: drop-shadow(0 0 8px var(--weather-accent));
}

.weather-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.weather-name {
  font-weight: 800;
  color: #f7faf8;
  font-size: 1.02em;
  letter-spacing: -0.01em;
}

.weather-effect {
  font-size: 0.82em;
  font-weight: 600;
  color: var(--weather-accent);
  padding: 2px 8px;
  background-color: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
}

/* Weather track overlays */
.track.weather-sunny {
  /* No special effect for sunny */
}

/* Weather moves on its own layer, leaving the track and lanes untouched. */
.track.weather-rainy::before,
.track.weather-windy::before,
.track.weather-stormy::before {
  content: '';
  position: absolute;
  inset: -100px;
  pointer-events: none;
  z-index: 0;
}

.track.weather-rainy::before {
  background-image: linear-gradient(0deg, rgba(30, 30, 30, 0.7) 0%, rgba(30, 30, 30, 0) 100%), 
                   url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><g fill="%231E90FF" opacity="0.3"><rect x="10" y="0" width="1" height="20" transform="rotate(15)"/><rect x="20" y="5" width="1" height="25" transform="rotate(15)"/><rect x="30" y="0" width="1" height="30" transform="rotate(15)"/><rect x="40" y="10" width="1" height="20" transform="rotate(15)"/><rect x="50" y="5" width="1" height="25" transform="rotate(15)"/><rect x="60" y="0" width="1" height="15" transform="rotate(15)"/><rect x="70" y="10" width="1" height="30" transform="rotate(15)"/><rect x="80" y="5" width="1" height="25" transform="rotate(15)"/><rect x="90" y="0" width="1" height="20" transform="rotate(15)"/></g></svg>');
  animation: rain-animation 20s linear infinite;
}

.track.weather-windy::before {
  background-image: linear-gradient(0deg, rgba(30, 30, 30, 0.7) 0%, rgba(30, 30, 30, 0) 100%), 
                   url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><g fill="%23FFFFFF" opacity="0.2"><path d="M10,30 Q30,10 50,30 T90,30"/><path d="M5,50 Q25,30 45,50 T85,50"/><path d="M15,70 Q35,50 55,70 T95,70"/></g></svg>');
  animation: wind-animation 15s linear infinite;
}

.track.weather-stormy::before {
  background-color: rgba(110, 110, 170, 0.15);
  animation: stormy-animation 5s ease-in-out infinite;
}

.track.weather-foggy {
  background-image: linear-gradient(0deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.02));
}

/* Lightning effect */
.lightning-effect {
  position: fixed;
  width: 96px;
  height: 112px;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 80"><ellipse cx="32" cy="10" rx="22" ry="7" fill="%23182442"/><path d="M34 8 L18 36 L31 36 L20 66 L48 32 L34 32 L44 8 Z" fill="%2300E5FF" stroke="%23B388FF" stroke-width="2"/><path d="M33 12 L22 35 L32 35 L24 58 L43 34 L33 34 Z" fill="%23FFFFFF"/><ellipse cx="26" cy="68" rx="18" ry="5" fill="none" stroke="%23FFE57F" stroke-width="2.5"/></svg>');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  z-index: 90;
  filter: drop-shadow(0 0 12px #00E5FF) drop-shadow(0 0 22px #B388FF);
  opacity: 0;
  animation: lightning-flash 1s forwards;
  pointer-events: none;
}

/* Boost effect */
.boost-effect {
  position: fixed;
  width: 40px;
  height: 20px;
  background-image: linear-gradient(to left, rgba(255, 87, 34, 0.7), rgba(255, 87, 34, 0));
  z-index: 9998;
  border-radius: 10px;
  animation: boost-anim 0.8s forwards;
  pointer-events: none;
}
/* Keep weather in the race layout so it cannot cover the timer or header. */
.race-track > .weather-indicator {
  position: relative;
  top: auto;
  left: auto;
  transform: none;
  width: max-content;
  max-width: 100%;
  margin: 0 auto 12px;
  animation: none;
  z-index: 1;
}

/* ---- css/modules/animations.css ---- */
/* Animation keyframes */
@keyframes gallop {
  0% {
    transform: translateY(0) scaleX(1);
  }
  25% {
    transform: translateY(-5px) scaleX(1.05);
  }
  50% {
    transform: translateY(0) scaleX(0.95);
  }
  75% {
    transform: translateY(5px) scaleX(1);
  }
  100% {
    transform: translateY(0) scaleX(1);
  }
}

@keyframes loading-pulse {
  0% {
    opacity: 0.3;
    transform: translateY(0);
    color: var(--color-text);
  }
  100% {
    opacity: 1;
    transform: translateY(-5px);
    color: var(--color-primary);
    text-shadow: var(--glow-primary);
  }
}

@keyframes progress {
  0% {
    width: 0;
  }
  100% {
    width: 100%;
  }
}

@keyframes hero-glow {
  0% {
    text-shadow: 
      0 0 5px var(--color-primary),
      0 0 10px var(--color-primary),
      0 0 20px rgba(255, 0, 255, 0.5);
  }
  100% {
    text-shadow: 
      0 0 10px var(--color-primary),
      0 0 20px var(--color-primary),
      0 0 30px rgba(255, 0, 255, 0.7),
      0 0 40px rgba(255, 0, 255, 0.4);
  }
}

@keyframes glitch-anim-1 {
  0% {
    clip: rect(20px, 450px, 39px, 0);
  }
  20% {
    clip: rect(31px, 450px, 36px, 0);
  }
  40% {
    clip: rect(95px, 450px, 53px, 0);
  }
  60% {
    clip: rect(67px, 450px, 59px, 0);
  }
  80% {
    clip: rect(53px, 450px, 48px, 0);
  }
  100% {
    clip: rect(76px, 450px, 63px, 0);
  }
}

@keyframes glitch-anim-2 {
  0% {
    clip: rect(54px, 450px, 99px, 0);
  }
  20% {
    clip: rect(44px, 450px, 36px, 0);
  }
  40% {
    clip: rect(81px, 450px, 91px, 0);
  }
  60% {
    clip: rect(32px, 450px, 100px, 0);
  }
  80% {
    clip: rect(26px, 450px, 78px, 0);
  }
  100% {
    clip: rect(61px, 450px, 71px, 0);
  }
}

@keyframes glitch-skew {
  0% {
    transform: skew(0deg, 0deg);
  }
  20% {
    transform: skew(0.5deg, 0deg);
  }
  40% {
    transform: skew(-0.5deg, 0deg);
  }
  60% {
    transform: skew(0.3deg, 0deg);
  }
  80% {
    transform: skew(-0.3deg, 0deg);
  }
  100% {
    transform: skew(0.3deg, 0deg);
  }
}

@keyframes timer-shine {
  0% { transform: translateX(-200%); }
  20%, 100% { transform: translateX(200%); }
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(255, 0, 255, 0.7);
  }
  70% {
    box-shadow: 0 0 0 15px rgba(255, 0, 255, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(255, 0, 255, 0);
  }
}

@keyframes pulse-gold {
  from { box-shadow: 0 0 10px rgba(255, 215, 0, 0.6); }
  to { box-shadow: 0 0 20px rgba(255, 215, 0, 0.9); }
}

@keyframes float {
  from { transform: translateY(-2px); }
  to { transform: translateY(2px); }
}

@keyframes finish-line-flash {
  0%, 100% { 
    box-shadow: 0 0 10px var(--color-primary), 0 0 20px var(--color-primary); 
    width: 2px;
  }
  50% { 
    box-shadow: 0 0 30px var(--color-primary), 0 0 50px var(--color-primary), 0 0 70px var(--color-primary); 
    width: 4px;
  }
}

@keyframes modal-in {
  0% {
    transform: perspective(1000px) rotateX(10deg) translateY(-50px);
    opacity: 0;
  }
  100% {
    transform: perspective(1000px) rotateX(0deg) translateY(0);
    opacity: 1;
  }
}

@keyframes horse-finish {
  0% { transform: scale(1) rotate(0); }
  25% { transform: scale(1.3) rotate(-10deg); }
  50% { transform: scale(1.5) rotate(10deg); }
  75% { transform: scale(1.3) rotate(-5deg); }
  100% { transform: scale(1) rotate(0); }
}

/* Size digits separately from translated start words, including スタート！. */
.countdown-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background-color: rgba(0, 0, 0, 0.7);
  z-index: 1000;
}

.countdown-text {
  font-size: clamp(3rem, min(20vw, 28vh), 10rem);
  font-weight: bold;
  line-height: 1.1;
  text-align: center;
  white-space: nowrap;
  color: #fff;
  text-shadow: 0 0 20px rgba(255, 255, 255, 0.8);
  transition: transform 0.3s, opacity 0.3s;
  transform: scale(0.5);
  opacity: 0;
}

.countdown-go {
  /* The longest translation fits even at the peak of its 1.15x animation. */
  font-size: clamp(1.5rem, min(10vw, 18vh), 6rem);
}

@keyframes zoom-boost {
  0% { transform: scale(1); }
  50% { transform: scale(1.3); }
  100% { transform: scale(1); }
}

@keyframes ranking-fade-in {
  from {
    transform: translateX(20px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes weather-fade-in {
  from { 
    transform: translateY(-20px) translateX(-50%);
    opacity: 0;
  }
  to { 
    transform: translateY(0) translateX(-50%);
    opacity: 1;
  }
}

@keyframes weather-icon-float {
  from { transform: translateY(-3px); }
  to { transform: translateY(3px); }
}

@keyframes rain-animation {
  from { transform: translate(0, 0); }
  to { transform: translate(100px, 100px); }
}

@keyframes wind-animation {
  from { transform: translate(0, 0); }
  to { transform: translate(-100px, 0); }
}

@keyframes stormy-animation {
  0%, 48%, 52%, 98%, 100% { opacity: 0; }
  50% { opacity: 1; }
}

@keyframes lightning-flash {
  0% {
    opacity: 0;
    transform: scale(0.5);
  }
  20% {
    opacity: 1;
    transform: scale(1.2);
  }
  40% {
    opacity: 0.8;
    transform: scale(0.9);
  }
  60% {
    opacity: 1;
    transform: scale(1.1);
  }
  100% {
    opacity: 0;
    transform: scale(0.5);
  }
}

/* Simplified lightning flash animation for low performance mode */
@keyframes lightning-flash-simple {
  0% {
    opacity: 0;
  }
  25% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

@keyframes boost-anim {
  0% {
    opacity: 1;
    transform: scaleX(0.67);
  }
  100% {
    opacity: 0;
    transform: scaleX(1.67);
  }
}

/* Simplified boost animation for low performance mode */
@keyframes boost-anim-simple {
  0% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateX(-20px);
  }
}

@keyframes resting {
  0% { transform: translateY(0); }
  50% { transform: translateY(3px); }
  100% { transform: translateY(0); }
}

@keyframes immunity {
  0% { box-shadow: 0 0 10px #FFEB3B, 0 0 20px #FFEB3B; }
  50% { box-shadow: 0 0 15px #FFEB3B, 0 0 30px #FFEB3B; }
  100% { box-shadow: 0 0 10px #FFEB3B, 0 0 20px #FFEB3B; }
}

@keyframes event-fade-in {
  from {
    transform: translateX(-20px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes green-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.7);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(76, 175, 80, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(76, 175, 80, 0);
  }
}

@keyframes red-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(255, 59, 59, 0.7);
  }
  70% {
    box-shadow: 0 0 0 6px rgba(255, 59, 59, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(255, 59, 59, 0);
  }
}

/* One reusable rule prevents keyframe growth after each race. */
@keyframes race-particle {
  0% { opacity: 0; transform: translate(0, 0) scale(0); }
  35% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--particle-x), var(--particle-y)) scale(1); }
}

@keyframes race-particle-simple {
  from { opacity: 0.6; transform: scale(0.5); }
  to { opacity: 0; transform: scale(1); }
}

/* ---- css/modules/language-selector.css ---- */
/* Styles for language selector in header - now removed */
.language-selector {
  display: none;
}

/* Styles for language selection in the menu */
.language-section {
  padding: 20px;
}

.language-options {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 20px 0;
}

.language-option {
  padding: 10px 20px;
  background-color: rgba(0, 0, 0, 0.3);
  color: #fff;
  border: 1px solid rgba(76, 175, 80, 0.3);
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
  transition: all 0.3s ease;
}

.language-option:hover {
  background-color: rgba(76, 175, 80, 0.2);
  border-color: rgba(76, 175, 80, 0.6);
}

.language-option.active {
  background-color: rgba(76, 175, 80, 0.3);
  border-color: rgba(76, 175, 80, 0.8);
  box-shadow: 0 0 8px rgba(76, 175, 80, 0.4);
}

.language-note {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.7);
  margin-top: 15px;
  text-align: center;
}

/* Language modal styles */
.language-settings-container {
  padding: 20px;
}

.language-options-large {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(250px, 100%), 1fr));
  gap: 20px;
  margin: 30px 0;
}

.language-option-large {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 30px;
  border-radius: 12px;
  background-color: rgba(20, 20, 20, 0.7);
  border: 2px solid rgba(76, 175, 80, 0.3);
  transition: all 0.3s ease;
  cursor: pointer;
}

.language-option-large:hover {
  border-color: #4CAF50;
  box-shadow: 0 0 20px rgba(76, 175, 80, 0.3);
  transform: translateY(-5px);
}

.language-option-large.active {
  border-color: #4CAF50;
  background-color: rgba(76, 175, 80, 0.2);
}

.language-flag {
  font-size: 32px;
  margin-bottom: 20px;
}

.language-name {
  font-size: 18px;
  font-weight: bold;
  color: white;
}

.language-info {
  padding: 20px;
  margin-top: 20px;
  background-color: rgba(0, 0, 0, 0.3);
  border-radius: 8px;
  text-align: center;
}

.current-language {
  margin-top: 15px;
  font-weight: bold;
  color: #4CAF50;
}

@media (max-width: 520px) {
  .language-settings-container { padding: 0; }
  .language-options-large { grid-template-columns: minmax(0, 1fr); gap: 10px; margin: 12px 0 18px; }
  .language-option-large { flex-direction: row; justify-content: flex-start; gap: 14px; min-width: 0; min-height: 60px; padding: 12px 16px; }
  .language-option-large:hover { transform: none; }
  .language-flag { flex-shrink: 0; font-size: 25px; margin: 0; }
  .language-name { font-size: 16px; }
  .language-info { margin-top: 0; padding: 14px; font-size: 12px; line-height: 1.7; }
  .language-note { margin-top: 0; font-size: 12px; line-height: 1.7; }
  .current-language { margin-top: 12px; font-size: 13px; }
}

/* ---- css/modules/performance.css ---- */
/* Keep decorative work separate from race movement and game state. */
.race-particles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  overflow: hidden;
  contain: strict;
}

.race-particle {
  position: absolute;
  border-radius: 50%;
  animation: race-particle 3s ease-out forwards;
}

.race-particle-simple {
  animation-name: race-particle-simple;
}

body:is([data-performance="low"], [data-performance="ultraLow"], .low-performance-mode)
:is(.horse, .track-condition, .obstacle-emoji, .weather-icon, .finish-line, .glitch-text, .hero h1, .pulse-effect) {
  animation: none !important;
  filter: none !important;
  box-shadow: none !important;
}

body:is([data-performance="low"], [data-performance="ultraLow"], .low-performance-mode)
:is(.race-results, .ranking-container, .weather-indicator, .event-message, .countdown-overlay, .modal, .feature-card, .quickbet-panel) {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

body:is([data-performance="low"], [data-performance="ultraLow"], .low-performance-mode) :is(.btn-primary, .glitch-text)::before,
body:is([data-performance="low"], [data-performance="ultraLow"], .low-performance-mode) :is(.timer, .feature-card, .glitch-text)::after,
body:is([data-performance="low"], [data-performance="ultraLow"], .low-performance-mode) .noise-overlay {
  display: none;
}

body:is([data-performance="low"], [data-performance="ultraLow"], .low-performance-mode) .track::before {
  animation: none;
  will-change: auto;
}

body:is([data-performance="low"], [data-performance="ultraLow"], .low-performance-mode) .track-condition {
  background-image: none !important;
}

body:is([data-performance="low"], [data-performance="ultraLow"], .low-performance-mode) .horse.lightning-immune {
  border-color: #FFEB3B;
}

body:is([data-performance="low"], [data-performance="ultraLow"], .low-performance-mode) .horse.finishing {
  border-color: white;
}

body[data-performance="ultraLow"] :is(.obstacle-emoji, .race-particles) {
  display: none;
}

/* Keep racing readable when the system requests less decorative motion. */
@media (prefers-reduced-motion: reduce) {
  .horse, .track-condition, .obstacle-emoji, .weather-icon,
  .track::before, .timer::after, .glitch-text, .glitch-text::before,
  .glitch-text::after, .hero h1, .pulse-effect {
    animation: none !important;
  }
}

/* Stop decorative work once the race has finished or the page is backgrounded. */
body:not(.race-active) .track :is(.horse, .obstacle-emoji, .track-condition, .finish-line),
body:not(.race-active) .track::before,
body:not(.race-active) .timer::after,
body.page-hidden *, body.page-hidden *::before, body.page-hidden *::after {
  animation-play-state: paused !important;
}

.ranking-time:empty { display: none; }

/* ---- css/modules/scene.css ---- */
/* The simulation DOM remains measurable; only the canvas presentation is painted. */
.simulation-lanes { position: absolute; inset: 0; visibility: hidden; opacity: 0; pointer-events: none; }
.simulation-lanes * { visibility: hidden !important; animation: none !important; transition: none !important; }
.locale-links { display: flex; justify-content: center; gap: 20px; margin-top: 14px; font-size: 13px; }
.locale-links a { color: #c4caca; text-decoration: none; }
.locale-links a:hover { color: #fff; text-decoration: underline; }
.race-track.has-race-scene { padding: 52px max(16px, calc((100% - 1440px) / 2)) 28px; background: #101d24; color: #edf4ed; }
.has-race-scene .scene-track { padding: 0; min-height: 0; height: clamp(360px, 58vh, 660px); border: 1px solid #4e6569; border-radius: 18px; overflow: hidden; background: #233e4a; box-shadow: 0 16px 40px #0003; }
.scene-track::before, .scene-track::after { display: none !important; }
.race-canvas { display: block; width: 100%; height: 100%; cursor: crosshair; }
.broadcast-heading { display: flex; align-items: center; gap: 18px; padding-bottom: 18px; }
.broadcast-heading > div { display: flex; align-items: center; gap: 12px; }
.broadcast-heading h2 { margin: 0; font-size: clamp(18px, 2vw, 25px); font-weight: 700; letter-spacing: -.5px; }
.broadcast-live { color: #b8f393; font-size: 10px; letter-spacing: 2px; border: 1px solid #73996a; padding: 5px 7px; border-radius: 5px; }
.broadcast-status { margin-left: auto; font-size: 12px; color: #c1d2ce; max-width: 30%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.broadcast-status.is-announcing { color: #e4f8ad; font-weight: 700; }
.broadcast-status [hidden] { display: none; }
.broadcast-heading .timer { flex-shrink: 0; margin: 0; padding: 4px 0; border: 0; background: transparent; box-shadow: none; color: #f1ddae; font-size: 22px; text-shadow: none; }
.broadcast-heading .timer::after { display: none; }
.broadcast-controls { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.broadcast-tools { display: flex; flex: 1; justify-content: flex-end; gap: 12px; align-items: center; }
.broadcast-tools-toggle { display: none; }
.camera-options, .character-options, .zoom-options { display: flex; padding: 4px; border: 1px solid #3b5057; border-radius: 10px; gap: 3px; background: #182a32; }
.character-options { margin-left: auto; }
.broadcast-controls button { color: #bdcfcb; padding: 8px 12px; min-height: 38px; border: 0; border-radius: 6px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.broadcast-controls button[aria-pressed="true"] { background: #dfebc8; color: #183233; }
.broadcast-controls button:hover { background: #344e54; color: #fff; }
.broadcast-controls button:focus-visible, .position-card:focus-visible { outline: 2px solid #d2ecc0; outline-offset: 3px; }
.zoom-options button { width: 36px; padding: 4px; font-size: 19px; }
.race-positions { padding-top: 24px; }
.positions-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.positions-heading h3 { margin: 0; font-size: 16px; }
.positions-heading p { margin: 0; color: #9bb0ad; font-size: 12px; }
.race-overview { position: absolute; top: 12px; left: 12px; width: min(268px, calc(100% - 24px)); height: var(--overview-height, 44px); margin: 0; border: 1px solid #9fd4be52; border-radius: 10px; background: linear-gradient(90deg, #132630e8, #1b3440e8); box-shadow: 0 6px 18px #0005; z-index: 3; pointer-events: none; }
.race-overview::before { content: ''; background: repeating-linear-gradient(to bottom, transparent 0 4px, #597c8044 4px 5px); position: absolute; left: 3%; right: 3%; top: 6px; bottom: 6px; }
.race-overview::after { content: ''; position: absolute; right: 3%; top: 6px; bottom: 6px; width: 5px; border-radius: 2px; background: repeating-linear-gradient(#f2f7e8 0 4px,#101d24 4px 8px); }
.overview-marker { position: absolute; width: 7px; height: 7px; border-radius: 50%; transform: translateX(-50%); background: var(--runner-color); border: 1.2px solid #fffc; box-shadow: 0 1px 3px #0009; color: transparent; font-size: 0; z-index: 1; transition: left .25s linear; }
.overview-marker.is-leader, .overview-marker.is-followed { width: 9px; height: 9px; z-index: 2; box-shadow: 0 0 0 1.5px #ffe285, 0 0 8px #ffe28588; }
.overview-marker.is-leader::after, .overview-marker.is-followed::after { content: attr(data-number); position: absolute; left: 9px; top: -6px; min-width: 18px; height: 18px; padding: 0 3px; border: 1px solid #ffe285; border-radius: 5px; background: #172e36; color: #fff6cf; font-size: 10px; line-height: 16px; text-align: center; font-weight: 800; }
.overview-marker.is-followed { z-index: 3; }
.overview-marker.is-followed::after { left: auto; right: 9px; background: #e1edc9; border-color: #e1edc9; color: #163136; }
.overview-marker.is-followed.at-start::after { left: 9px; right: auto; }
.overview-marker.is-leader.at-finish::after { left: auto; right: 9px; }
.position-list { display: grid; grid-template-columns: repeat(auto-fit,minmax(245px,1fr)); gap: 8px; }
.positions-heading { margin-bottom: 14px; }
.position-card { position: relative; display: grid; grid-template-columns: 30px 1fr 40px; align-items: center; gap: 9px; padding: 13px 12px 17px; border-radius: 11px; border: 1px solid #344e56; border-left: 4px solid var(--runner-color); background: linear-gradient(145deg, #1b2f37, #16262d); text-align: left; color: #ecf1e8; overflow: hidden; transition: border-color .2s, background .2s; }
.position-card[style*="order: 0"], .position-card[style*="order:0"] { border-color: #c8ad55; border-left: 4px solid #ffd86b; background: linear-gradient(145deg, #2b392c, #1c2c2f); }
.position-card:hover, .position-card[aria-pressed="true"] { background: #2a4145; border-color: #accc9c; }
.position-rank { display: inline-grid; place-items: center; min-width: 26px; height: 26px; border-radius: 7px; background: #102027; font-size: 16px; font-weight: 800; color: var(--runner-color); font-variant-numeric: tabular-nums; }
.position-card[style*="order: 0"] .position-rank, .position-card[style*="order:0"] .position-rank { background: #ffd86b24; color: #ffe285; }
.position-details { min-width: 0; display: grid; gap: 3px; }
.position-name { font-size: 13px; font-weight: 700; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
.position-detail { font-size: 10.5px; color: #a5bdbc; }
.position-percent { text-align: right; font-size: 12.5px; font-weight: 700; font-variant-numeric: tabular-nums; color: #dce9be; }
.position-meter { position: absolute; bottom: 0; left: 0; right: 0; height: 4px; background: #263c42; }
.position-fill { display: block; width: 100%; height: 100%; background: var(--runner-color); transform-origin: left; transition: transform .25s linear; }
.scene-track .event-container { position: absolute; left: 12px; right: 12px; bottom: 12px; top: auto; max-width: 480px; width: auto; transform: none; z-index: 3; pointer-events: none; }
.scene-track .event-message { color: #f6f4e7; border: 1px solid #ffffff21; padding: 7px 10px; margin: 5px 0 0; background: #182c39e8; box-shadow: none; font-size: 11px; border-radius: 7px; backdrop-filter: none; }
.scene-track .event-message:not(:last-child) { display: none; }
.has-race-scene .broadcast-heading .weather-indicator { position: static; display: inline-flex; flex-shrink: 0; width: auto; margin: 0; padding: 5px 10px; transform: none; background: linear-gradient(135deg, var(--weather-bg, #22383f), rgba(16, 29, 36, 0.95)); border: 1px solid var(--weather-border, #405960); border-radius: 999px; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1); font-size: 12px; animation: none; gap: 6px; }
.broadcast-heading .weather-info { flex-direction: row; align-items: center; gap: 6px; }
.broadcast-heading .weather-name { font-size: 11.5px; color: var(--weather-accent, #f2f7f5); font-weight: 800; }
.broadcast-heading .weather-effect { display: inline-block; font-size: 10px; padding: 1px 6px; margin: 0; background: rgba(255, 255, 255, 0.08); border-radius: 999px; color: #dbe7e4; }
@media (max-width: 520px) {
  .broadcast-heading .weather-effect { display: none; }
}
.has-race-scene .weather-icon { font-size: 18px; margin-right: 0; }
@media (max-width: 680px) {
  .race-track.has-race-scene { padding: 48px 10px 22px; }
  .broadcast-heading { gap: 8px; flex-wrap: wrap; padding-bottom: 10px; }
  .broadcast-heading > div { gap: 7px; }
  .broadcast-heading .timer { font-size: 18px; margin-left: auto; }
  .broadcast-status { order: 3; width: 100%; max-width: 100%; margin: 0; font-size: 11px; }
  .broadcast-controls { display: grid; grid-template-columns: minmax(0, 1fr) 44px; gap: 6px; margin-bottom: 8px; }
  .broadcast-controls button { padding: 5px 6px; font-size: 11px; min-height: 44px; }
  .camera-options { min-width: 0; padding: 2px; gap: 2px; justify-content: space-between; }
  .camera-options button { min-width: 44px; }
  .broadcast-controls .broadcast-tools-toggle { display: block; width: 44px; height: 44px; padding: 0; font-size: 25px; border: 1px solid #3b5057; background: #182a32; }
  .broadcast-tools { display: none; grid-column: 1 / -1; justify-content: space-between; gap: 6px; }
  .broadcast-tools.is-expanded { display: flex; }
  .character-options { margin-left: 0; }
  .character-options, .zoom-options { padding: 2px; gap: 2px; }
  .character-options button { min-width: 44px; }
  .zoom-options button { width: 44px; font-size: 19px; }
  .has-race-scene .scene-track { height: 430px; max-height: 62vh; min-height: 320px; border-radius: 12px; }
  .position-list { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 6px; }
  .position-card { grid-template-columns: 23px 1fr 28px; padding: 10px 7px 14px; gap: 5px; }
  .position-name { font-size: 11px; }
  .position-rank { font-size: 17px; }
  .positions-heading { display: block; }
  .positions-heading p { margin-top: 6px; font-size: 11px; }
}
@media (max-width: 360px) {
  .position-card { grid-template-columns: 23px minmax(0, 1fr); gap: 3px 5px; padding: 8px 7px 12px; }
  .position-rank { grid-row: 1 / 3; }
  .position-details { grid-column: 2; }
  .position-percent { grid-column: 2; font-size: 10px; line-height: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .overview-marker, .position-fill { transition: none; }
}

/* ---- css/modules/spectator.css ---- */
/* Small static viewing cues; updates share the existing 200/400ms HUD. */
#settingsModal .race-favorite-setting {
  margin: 0 0 18px;
  padding: 14px;
  border: 1px solid rgba(232, 212, 139, 0.34);
  border-radius: 14px;
  background:
    radial-gradient(circle at 100% 0%, rgba(255, 216, 107, 0.12), transparent 55%),
    linear-gradient(155deg, rgba(28, 45, 48, 0.92), rgba(18, 32, 36, 0.96));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

#settingsModal .form-group.race-favorite-setting > label,
#settingsModal .race-favorite-setting > label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #f6e7b2;
  font-weight: 800;
  font-size: 13.5px;
  margin-bottom: 10px;
}

#settingsModal .race-favorite-setting > label::before {
  content: '📣';
  font-size: 15px;
}

#raceFavorite {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid #52675f;
  border-radius: 10px;
  background: #14292d;
  color: #f1f4e6;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.4;
}

#raceFavorite.favorite-native-select {
  display: none;
}

#raceFavorite:focus-visible {
  outline: 2px solid #e7d58e;
  outline-offset: 3px;
}

.favorite-chip-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  max-height: 224px;
  overflow-y: auto;
  padding: 2px 2px 4px;
  scrollbar-width: thin;
}

.favorite-chip {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 7px 10px;
  border: 1px solid rgba(116, 150, 154, 0.36);
  border-left: 3.5px solid var(--chip-color, #9eb8b5);
  border-radius: 10px;
  background: rgba(17, 33, 39, 0.88);
  color: #e4ede9;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 650;
  text-align: left;
  cursor: pointer;
  transition: transform 0.14s ease, border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

.favorite-chip-all {
  grid-column: 1 / -1;
  border-left-width: 1px;
  justify-content: center;
  background: rgba(25, 45, 51, 0.9);
  color: #d7e6e1;
}

.favorite-chip:hover {
  background: rgba(34, 58, 65, 0.95);
  border-color: rgba(213, 239, 150, 0.55);
  transform: translateY(-1px);
}

.favorite-chip[aria-pressed="true"],
.favorite-chip.is-selected {
  background: linear-gradient(135deg, rgba(64, 58, 32, 0.92), rgba(34, 49, 44, 0.96));
  border-color: #f3dc8a;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.28), inset 0 0 0 1px rgba(243, 220, 138, 0.45);
  color: #fff8dc;
}

.favorite-chip-badge {
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  min-width: 24px;
  height: 24px;
  padding: 0 5px;
  border-radius: 6px;
  background: var(--chip-color, rgba(255, 255, 255, 0.12));
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55);
}

.favorite-chip-all .favorite-chip-badge {
  background: rgba(243, 220, 138, 0.18);
  font-size: 13px;
  text-shadow: none;
}

.favorite-chip-text {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.favorite-chip-all .favorite-chip-text {
  flex: 0 1 auto;
}

.favorite-chip-star {
  flex-shrink: 0;
  font-size: 13px;
  color: #ffd86b;
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.favorite-chip[aria-pressed="true"] .favorite-chip-star,
.favorite-chip.is-selected .favorite-chip-star {
  opacity: 1;
  transform: scale(1);
}

.race-favorite {
  --favorite-color: #f1da88;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  padding: 12px 15px;
  border: 1px solid rgba(241, 218, 136, 0.52);
  border-left: 5px solid var(--favorite-color, #f1da88);
  border-radius: 13px;
  background:
    radial-gradient(circle at 0% 50%, rgba(241, 218, 136, 0.14), transparent 55%),
    linear-gradient(135deg, #243631, #19292c);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.race-favorite[hidden] { display: none; }
.race-favorite-copy { display: grid; gap: 3px; min-width: 0; flex: 1 1 160px; }
.race-favorite-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  width: fit-content;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(241, 218, 136, 0.16);
  border: 1px solid rgba(241, 218, 136, 0.35);
  color: #ffe699;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.02em;
}
.race-favorite-label::before { content: '★'; color: #ffd86b; }
.race-favorite-name { color: #fff9e6; font-size: 14px; font-weight: 800; line-height: 1.35; overflow-wrap: anywhere; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.race-favorite-rank {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(15, 28, 33, 0.75);
  border: 1px solid rgba(241, 218, 136, 0.35);
  color: #ffefb5;
  font-size: 12.5px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.race-favorite-stats { display: contents; }
.race-favorite-movement { color: #d5ef96; font-size: 11.5px; font-weight: 700; }
.race-favorite-follow {
  flex-shrink: 0;
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid rgba(241, 218, 136, 0.55);
  border-radius: 999px;
  background: rgba(54, 64, 45, 0.9);
  color: #fff6d6;
  font-size: 12px;
  font-weight: 700;
  transition: background 0.16s ease, transform 0.14s ease;
}
.race-favorite-follow:hover { background: rgba(74, 86, 58, 0.95); }
.race-favorite-follow[aria-pressed="true"] {
  background: linear-gradient(135deg, #f3dc8a, #e2c15a);
  border-color: #fff0b3;
  color: #1c2b25;
  box-shadow: 0 0 12px rgba(243, 220, 138, 0.4);
}
.race-favorite-follow:focus-visible { outline: 2px solid #e7d58e; outline-offset: 3px; }
.position-card.is-favorite {
  border-color: #dec468;
  box-shadow: inset 3px 0 #f3dc8a, 0 0 0 1px rgba(243, 220, 138, 0.25);
  background: linear-gradient(145deg, #28382f, #19292c);
}
.overview-marker.is-favorite { z-index: 2; box-shadow: 0 0 0 2px #f1da88, 0 0 8px rgba(241, 218, 136, 0.7); }
.overview-marker.is-favorite::after { content: attr(data-number); position: absolute; left: 8px; top: -7px; min-width: 18px; height: 18px; padding: 0 2px; border: 1px solid #e8dca5; border-radius: 5px; background: #e8dca5; color: #26342c; font-size: 10px; line-height: 16px; text-align: center; font-weight: 700; }
.overview-marker.is-favorite.at-finish::after { left: auto; right: 8px; }
#raceResults .result-story { margin: 0 0 18px; padding-bottom: 16px; border-bottom: 1px solid #344a48; }
#raceResults .result-favorite, #raceResults .result-comeback { padding: 13px 15px; margin: 0 0 14px; border: 1px solid #8a7c48; border-radius: 12px; background: linear-gradient(145deg, #2a392e, #1d2c28); }
#raceResults .result-comeback { border-color: #3d5c59; background: #1a3032; }
#raceResults .result-story-label { margin: 0 0 5px; font-size: 11px; color: #f0df9c; font-weight: 700; }
#raceResults .result-story-name { display: block; color: #edf3de; font-size: 14px; overflow-wrap: anywhere; }
#raceResults .result-story-detail { margin: 6px 0 0; color: #c7d3bf; font-size: 12px; line-height: 1.5; font-variant-numeric: tabular-nums; }
#raceResults .result-favorite-win { display: inline-block; margin-top: 8px; padding: 4px 8px; border-radius: 5px; background: #e6d790; color: #23342c; font-size: 11px; font-weight: 700; }
#raceResults .result-story-title { margin: 17px 0 8px; font-size: 15px; color: #edf3de; }
#raceResults .result-lead-count { margin: 0 0 12px; color: #c1d7c2; font-size: 12px; line-height: 1.6; }
#raceResults .result-highlight-details { padding: 0; border: 1px solid #3b524e; border-radius: 8px; background: #162c2e; }
#raceResults .result-highlight-details summary { padding: 11px 12px; color: #dce6cc; font-size: 12px; cursor: pointer; min-height: 44px; }
#raceResults .result-highlight-details summary:focus-visible { outline: 2px solid #d5ef96; outline-offset: 2px; }
#raceResults .result-highlight-list { list-style: none; padding: 0 12px 12px; margin: 0; }
#raceResults .result-highlight-list li { display: grid; grid-template-columns: 68px minmax(0, 1fr); align-items: baseline; gap: 10px; padding: 8px 0; border-top: 1px solid #344a48; color: #c5d5c8; font-size: 11px; line-height: 1.6; overflow-wrap: anywhere; }
#raceResults .result-highlight-time { color: #e4d394; font-variant-numeric: tabular-nums; }
#raceResults .result-story-hint { margin: 10px 0 0; color: #96aeaa; font-size: 10px; line-height: 1.6; }

/* Light mode palette for favorite horse picker & live cheer banner */
html[data-theme="light"] #settingsModal .race-favorite-setting {
  border-color: #bdd3c8;
  background:
    radial-gradient(circle at 100% 0%, rgba(235, 194, 77, 0.16), transparent 55%),
    linear-gradient(155deg, #f8fcf9, #eef6f1);
  box-shadow: 0 2px 8px rgba(32, 68, 52, 0.06), inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

html[data-theme="light"] #settingsModal .form-group.race-favorite-setting > label,
html[data-theme="light"] #settingsModal .race-favorite-setting > label {
  color: #214939;
}

html[data-theme="light"] #settingsModal .favorite-chip {
  border-color: #bfd4c9;
  border-left: 3.5px solid var(--chip-color, #4a7c66);
  background: #ffffff;
  color: #243f36;
  box-shadow: 0 1px 3px rgba(28, 58, 45, 0.05);
}

html[data-theme="light"] #settingsModal .favorite-chip-all {
  border-left-width: 1px;
  background: #edf5f0;
  color: #274b3e;
}

html[data-theme="light"] #settingsModal .favorite-chip:hover {
  background: #e6f3ec;
  border-color: #4b896c;
  border-left-color: var(--chip-color, #32674f);
}

html[data-theme="light"] #settingsModal .favorite-chip[aria-pressed="true"],
html[data-theme="light"] #settingsModal .favorite-chip.is-selected {
  background: linear-gradient(135deg, #fffbeb, #e6f4ec);
  border-color: #d4a017;
  border-left-color: var(--chip-color, #d4a017);
  box-shadow: 0 3px 10px rgba(180, 134, 18, 0.16), inset 0 0 0 1px rgba(212, 160, 23, 0.38);
  color: #1b3a2e;
}

html[data-theme="light"] #settingsModal .favorite-chip-all .favorite-chip-badge {
  background: rgba(50, 103, 79, 0.14);
  color: #23493a;
}

html[data-theme="light"] #settingsModal .favorite-chip-star {
  color: #d99b00;
}

html[data-theme="light"] body.game-portal #raceTrack .race-favorite {
  border-color: #d1b866;
  border-left: 5px solid var(--favorite-color, #d4a017);
  background:
    radial-gradient(circle at 0% 50%, rgba(235, 194, 77, 0.18), transparent 55%),
    linear-gradient(135deg, #fdfcf5, #eef6f0);
  box-shadow: 0 4px 14px rgba(32, 62, 48, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

html[data-theme="light"] body.game-portal #raceTrack .race-favorite-label {
  background: #fff4cc;
  border-color: #dfb94b;
  color: #6e510b;
}

html[data-theme="light"] body.game-portal #raceTrack .race-favorite-label::before {
  color: #d49500;
}

html[data-theme="light"] body.game-portal #raceTrack .race-favorite-name {
  color: #1f3b31;
}

html[data-theme="light"] body.game-portal #raceTrack .race-favorite-rank {
  background: #e6f2eb;
  border-color: #a9c7b7;
  color: #214d3a;
}

html[data-theme="light"] body.game-portal #raceTrack .race-favorite-movement {
  color: #2f6849;
}

html[data-theme="light"] body.game-portal #raceTrack .race-favorite-follow {
  background: #e4f1e9;
  color: #234d3a;
  border-color: #9ec0ae;
}

html[data-theme="light"] body.game-portal #raceTrack .race-favorite-follow:hover {
  background: #d3e8dc;
}

html[data-theme="light"] body.game-portal #raceTrack .race-favorite-follow[aria-pressed="true"] {
  background: linear-gradient(135deg, #32674f, #26533e);
  color: #ffffff;
  border-color: #26533e;
  box-shadow: 0 2px 8px rgba(38, 83, 62, 0.25);
}

html[data-theme="light"] body.game-portal #raceTrack .position-card.is-favorite {
  background: linear-gradient(145deg, #fffdf4, #eef7f1);
  border-color: #d4b459;
  box-shadow: inset 3px 0 #e0a82e, 0 2px 6px rgba(24, 52, 42, 0.06);
}
@media (max-width: 680px) {
  .favorite-chip-grid { max-height: 196px; gap: 6px; }
  .favorite-chip { min-height: 40px; padding: 6px 8px; font-size: 12px; }
  .race-favorite { display: grid; grid-template-columns: minmax(0, 1fr) 44px; gap: 4px 10px; padding: 9px 11px; margin-bottom: 8px; }
  .race-favorite-copy { grid-column: 1; gap: 2px; }
  .race-favorite-label { font-size: 9px; padding: 1px 6px; }
  .race-favorite-name { display: block; font-size: 12.5px; white-space: nowrap; text-overflow: ellipsis; }
  .race-favorite-stats { display: flex; align-items: center; gap: 8px; min-width: 0; grid-column: 1; }
  .race-favorite-rank { flex-shrink: 0; font-size: 11px; padding: 2px 8px; }
  .race-favorite-movement { display: none; font-size: 10px; }
  .race-favorite.has-highlight .race-favorite-movement { display: block; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .race-favorite-follow { grid-column: 2; grid-row: 1 / 3; width: 44px; height: 44px; padding: 0; font-size: 0; border-radius: 10px; }
  .race-favorite-follow::after { content: attr(data-mobile-label); font-size: 11px; font-weight: 800; }
}

/* ---- css/modules/overlays.css ---- */
/* Shared stacking order: race/HUD < results < header < countdown < sheets. */
:root {
  --layer-results: 400;
  --layer-navigation: 500;
  --layer-countdown: 550;
  --layer-sheet: 600;
  --header-clearance: calc(76px + env(safe-area-inset-top, 0px));
}

html.dialog-open, body.dialog-open { overflow: hidden; }
.site-header { z-index: var(--layer-navigation); }
.btn-primary, #newRaceBtn { z-index: auto; }
.ranking-container, .weather-indicator { z-index: 100; }
.countdown-overlay { z-index: var(--layer-countdown); }

.main-menu-modal, .modal, .game-help-modal, .credits-modal {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  z-index: var(--layer-sheet);
  align-items: center;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  overflow: hidden;
  overscroll-behavior: none;
  background: rgba(5, 8, 15, 0.78);
  /* Opaque surfaces give readable overlays without fullscreen GPU blur. */
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.modal-content, .menu-modal-content, .help-modal-content, .credits-content {
  width: 100%;
  max-width: 620px;
  max-height: 100%;
  margin: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  border-radius: 18px;
  background: #121720;
  transform: none;
  -webkit-transform: none;
  transition: none;
  animation: none;
  -webkit-animation: none;
}

.modal-header, .menu-modal-header, .help-modal-header, .credits-header {
  position: sticky;
  top: -20px;
  z-index: 2;
  background: #121720;
}

.modal-header h2, .menu-modal-header h2, .help-modal-header h2, .credits-header h2 {
  min-width: 0;
  font-size: clamp(1.2rem, 4.5vw, 1.65rem);
  overflow-wrap: anywhere;
}

.close-modal, .close-modal-button, .back-button {
  flex: 0 0 auto;
  min-width: 44px;
  min-height: 44px;
}

#raceResults {
  z-index: var(--layer-results);
  top: calc(var(--header-clearance) + 12px);
  left: 50%;
  bottom: auto;
  transform: translateX(-50%);
  width: min(680px, calc(100% - 32px));
  max-width: 680px;
  max-height: calc(100vh - var(--header-clearance) - 28px);
  max-height: calc(100dvh - var(--header-clearance) - 28px - env(safe-area-inset-bottom, 0px));
  background: rgba(12, 17, 26, 0.97);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border-radius: 18px;
  isolation: isolate;
}

body.results-open::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: calc(var(--layer-results) - 1);
  background: rgba(4, 8, 14, 0.45);
  pointer-events: none;
}

#raceResults #newRaceBtn {
  position: sticky;
  bottom: 0;
  z-index: 2;
  box-shadow: 0 0 0 8px #10151e;
}

.modal-content:focus, .menu-modal-content:focus, .help-modal-content:focus, .credits-content:focus, #raceResults:focus { outline: none; }
:is(.modal-content, .menu-modal-content, .help-modal-content, .credits-content, #raceResults) :focus-visible {
  outline: 2px solid var(--color-secondary);
  outline-offset: 4px;
}

@media (max-width: 480px) {
  .modal-content, .menu-modal-content, .help-modal-content, .credits-content { padding: 16px; }
  .modal-header, .menu-modal-header, .help-modal-header, .credits-header { top: -16px; }
  #raceResults { padding: 18px 14px; }
}

/* ---- css/modules/ux.css ---- */
/* One restrained visual language for setup, broadcast and supporting screens. */
:root { color-scheme: dark; --color-primary: #d5ef96; --color-primary-rgb: 213,239,150; --color-secondary: #b9ddce; --color-accent: #d5ef96; --color-dark: #182a31; --color-darker: #101d24; --color-text: #f0f3e9; --color-text-muted: #a9bcbb; --glow-primary: none; --glow-secondary: none; --header-clearance: calc(72px + env(safe-area-inset-top, 0px)); }
body, html { background: #101d24; }
body { font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif; }
button, input, select, summary { touch-action: manipulation; }
button, a, summary, input, select { -webkit-tap-highlight-color: #d5ef9622; }
:where(button,a,summary,input,select):focus-visible { outline: 2px solid #d5ef96; outline-offset: 4px; }
button:disabled { opacity: .35; cursor: default; }
.site-header { height: calc(68px + env(safe-area-inset-top, 0px)); padding: env(safe-area-inset-top, 0px) 24px 0; background: #101d24; border-bottom: 1px solid #33464b; box-shadow: none; }
.logo { min-width: 0; padding-right: 115px; }
.logo a { text-decoration: none; min-width: 0; }
.logo-divider { background: #405258; margin: 0 14px; }
.neon-text { font-size: 27px; text-shadow: none; }
.neon-text-alt { color: #f0f3e9; font-size: 15px; text-shadow: none; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hamburger-menu { width: 44px; height: 44px; padding: 12px 10px; border: 1px solid #405258; border-radius: 10px; flex-shrink: 0; }
.hamburger-line { height: 2px; background: #dfe8d6; box-shadow: none; }
#fpsCounter { top: calc(20px + env(safe-area-inset-top, 0px)); right: calc(82px + env(safe-area-inset-right, 0px)); left: auto; width: 72px; height: 28px; padding: 3px 5px; font-size: 11px; line-height: 20px; color: #b4cba9; background: #1c3035; border: 1px solid #344c4f; border-radius: 6px; text-shadow: none; z-index: 501; }
main { padding-top: calc(68px + env(safe-area-inset-top, 0px)); }
.noise-overlay, .hero-overlay, .hero h1::before, .hero h1::after { display: none; }
.hero { min-height: min(670px,calc(100svh - 68px)); height: auto; display: grid; grid-template-columns: 1.05fr 1fr; gap: 50px; padding: 74px max(32px,calc((100vw - 1260px)/2)); background: #101d24; text-align: left; }
.hero-content { padding: 0; transform: none; max-width: 630px; }
.hero-eyebrow { color: #d5ef96; font-size: 13px; font-weight: 600; margin-bottom: 24px; letter-spacing: .04em; }
.hero h1 { font-size: clamp(36px,4.1vw,62px); font-weight: 800; line-height: 1.25; letter-spacing: -.06em; color: #f3f1e4; animation: none; text-shadow: none; margin: 0 0 24px; white-space: pre-line; word-break: keep-all; }
.hero-description { font-size: 16px; line-height: 1.9; color: #aebfbe; margin: 0 0 30px; max-width: 465px; opacity: 1; white-space: normal; word-break: keep-all; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-primary, .btn-secondary { min-height: 48px; padding: 12px 24px; border-radius: 10px; font-size: 15px; font-weight: 700; box-shadow: none; animation: none; text-decoration: none; transition: background .15s; text-align: center; }
.btn-primary { background: #d5ef96; color: #182c25; margin: 0; border: 1px solid #d5ef96; }
.btn-primary:hover { background: #e2f7b1; color: #182c25; box-shadow: none; transform: none; }
.btn-primary::before { display: none; }
.btn-secondary { border: 1px solid #50615f; color: #d7e1d8; background: transparent; }
.btn-secondary:hover { background: #21373b; }
.hero-facts { display: flex; flex-wrap: wrap; gap: 18px; margin-top: 23px; color: #96afaa; font-size: 11px; }
.hero-facts span::before { content: '✓'; color: #d5ef96; margin-right: 6px; }
.hero-art { background: #203740; border: 1px solid #435952; border-radius: 22px; overflow: hidden; transform: rotate(-3deg); box-shadow: 18px 22px 0 #172a30; }
.hero-art img { display: block; width: 100%; height: auto; }
.preview-heading, .preview-caption { display: flex; justify-content: space-between; align-items: center; padding: 20px 23px; }
.preview-heading { color: #e7eacd; font-size: 11px; font-weight: 700; letter-spacing: .13em; border-bottom: 1px solid #48615b; }
.preview-heading span:last-child { color: #a8b7a2; }
.preview-caption { background: #d5ef96; color: #294435; font-size: 12px; font-weight: 600; gap: 10px; }
.preview-caption span:last-child { font-size: 22px; }
.features { padding: 0 max(32px,calc((100vw - 1260px)/2)) 60px; background: #101d24; }
.features::before, .feature-card::after, .feature-card h3::after { display: none; }
.feature-container { grid-template-columns: repeat(3,minmax(0,1fr)); gap: 0; max-width: none; border-top: 1px solid #34464a; }
.feature-card { padding: 26px 28px 4px 0; background: none; border: 0; border-radius: 0; box-shadow: none; backdrop-filter: none; }
.feature-card + .feature-card { padding-left: 28px; }
.feature-card:hover { transform: none; box-shadow: none; }
.feature-number { font: 12px monospace; color: #91ac9e; display: block; margin-bottom: 12px; }
.feature-card h3 { font-size: 17px; margin: 0 0 9px; color: #e2e9d7; }
.feature-card p { font-size: 13px; line-height: 1.8; color: #a6b9b6; }
footer { background: #101d24; padding: 25px 20px; border-top: 1px solid #2e4247; font-size: 11px; }
.pulse-effect { animation: none; }
:is(.modal-content,.menu-modal-content,.help-modal-content,.credits-content) { background: #182a31; border: 1px solid #42595b; box-shadow: 0 24px 100px #0007; padding: 24px; border-radius: 18px; }
:is(.modal-header,.menu-modal-header,.help-modal-header,.credits-header) { background: #182a31; top: -24px; padding: 16px 0; margin: -10px 0 20px; border-bottom: 1px solid #3d5256; }
:is(.modal-header,.menu-modal-header,.help-modal-header,.credits-header) h2 { color: #f0f3e9; font-size: 21px; text-shadow: none; }
:is(.close-modal,.close-modal-button,.back-button) { border: 1px solid #3a5256; border-radius: 8px; color: #c4d4cf; font-size: 23px; transition: none; }
:is(.close-modal,.close-modal-button,.back-button):hover { transform: none; color: #eef6df; background: #31474b; }
.menu-buttons { gap: 8px; margin-bottom: 0; }
.menu-button { padding: 16px; font-size: 14px; border: 1px solid #3c5357; background: #1d333a; border-radius: 10px; }
.menu-button:hover { background: #304a4d; border-color: #8ca88d; transform: none; box-shadow: none; color: #e3f0d8; }
.menu-button-icon { font-size: 20px; }
.help-category-button, .language-option-large { border-color: #40595d; background: #1d333a; box-shadow: none; border-radius: 10px; }
.help-category-button:hover { background: #304a4d; }
#settingsModal .modal-content { display: flex; flex-direction: column; padding: 0; max-width: 660px; overflow: hidden; }
#settingsModal .modal-header { position: static; flex: none; margin: 0; padding: 18px 24px; }
.settings-form { padding: 0; overflow: auto; overscroll-behavior: contain; }
.settings-intro { padding: 20px 24px 0; color: #a8beba; font-size: 13px; }
.settings-basics { padding: 22px 24px 4px; }
#settingsModal .form-group { margin-bottom: 22px; }
#settingsModal .form-group label { font-size: 13px; font-weight: 600; margin-bottom: 12px; color: #deeadf; }
.range-slider-container { gap: 12px; }
.range-value { min-width: 55px; margin: 0; color: #e8efd8; font-size: 14px; font-variant-numeric: tabular-nums; text-align: right; }
.count-step { width: 44px; height: 44px; flex: 0 0 44px; padding: 0; border: 1px solid #4b6264; border-radius: 8px; color: #dcebcf; font-size: 20px; }
input[type=range] { min-width: 30px; height: 44px; background: transparent; cursor: pointer; }
input[type=range]::-webkit-slider-runnable-track { height: 6px; border-radius: 999px; background: #48625f; }
input[type=range]::-webkit-slider-thumb { width: 23px; height: 23px; margin-top: -8.5px; background: #d5ef96; border: 3px solid #203a34; box-shadow: 0 0 0 1px #8aab77; }
input[type=range]::-moz-range-track { height: 6px; border-radius: 999px; background: #48625f; }
input[type=range]::-moz-range-thumb { width: 19px; height: 19px; background: #d5ef96; border: 2px solid #203a34; box-shadow: none; }
.count-presets { display: flex; gap: 8px; margin: 14px 0 0; }
.count-presets button { border: 1px solid #4a6264; border-radius: 7px; min-height: 44px; min-width: 48px; font-size: 12px; color: #b8cbc2; }
.count-presets button[aria-pressed=true] { background: #d5ef96; border-color: #d5ef96; color: #1e392c; }
.track-options, .performance-options { display: flex; gap: 6px; }
.track-option, .performance-option { min-height: 44px; padding: 10px 8px; border: 1px solid #496266; background: #20373d; border-radius: 9px; font-size: 13px; flex: 1; color: #b9cbc5; box-shadow: none; }
.track-option.active, .performance-option.active { color: #20392c; background: #d5ef96; border-color: #d5ef96; box-shadow: none; }
.settings-disclosure { margin: 0 24px; border-top: 1px solid #3c5357; }
.settings-disclosure summary { cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 59px; padding: 16px 0; font-size: 14px; color: #dfebde; font-weight: 600; list-style: none; }
.settings-disclosure summary::-webkit-details-marker { display: none; }
.disclosure-chevron { color: #9bb6a3; font-size: 21px; font-weight: 400; }
.settings-disclosure[open] .disclosure-chevron { transform: rotate(45deg); }
.field-hint { font-size: 12px; color: #a4bbb5; margin: 0 0 18px; line-height: 1.7; }
.disclosure-body { padding-bottom: 4px; }
.settings-actions { position: sticky; bottom: 0; z-index: 3; padding: 16px 24px max(16px,env(safe-area-inset-bottom,0px)); background: #182a31; border-top: 1px solid #3d5559; }
.settings-actions .btn-primary { min-height: 49px; }
.horse-names-header { margin-bottom: 10px; align-items: center; gap: 12px; }
#settingsModal .horse-names-header label { display: none; }
.shuffle-btn { border-radius: 7px; padding: 8px 12px; min-height: 44px; font-size: 12px; border-color: #4a6264; color: #c8dcc8; background: #213b3f; }
.horse-names-container { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; max-height: none; padding: 0; overflow: visible; margin: 0; }
.horse-name-input { min-width: 0; margin: 0; padding: 6px 10px; border: 1px solid #3b555a; border-radius: 10px; background: #14272e; gap: 8px; align-items: center; }
.horse-name-input .horse-number { display: inline-grid; place-items: center; min-width: 24px; height: 24px; padding: 0 5px; border-radius: 6px; background: #203b42; border: 1px solid #486970; font: 800 11px/1 system-ui, sans-serif; color: #d5ef96; margin: 0; }
.horse-name-input input { width: 0; min-width: 0; padding: 7px 0; background: none; border: 0; border-radius: 0; font-size: 14px; font-weight: 600; color: #e0ebde; box-shadow: none; }
.horse-name-input input::placeholder { color: #91a9a8; font-size: 13px; }
.horse-name-input:focus-within { border-color: #bedf91; outline: 1px solid #bedf91; }
.horse-name-input input:focus { box-shadow: none; }
.weather-select, .bet-horse-select, .bet-amount { min-height: 44px; background-color: #14272e; border: 1px solid #4a6264; border-radius: 8px; color: #e3ecdf; font-size: 16px; padding: 10px 30px 10px 12px; }
.device-performance { font-size: 11px; line-height: 1.6; color: #a8bdb5; font-style: normal; }
.fps-toggle { margin-top: 14px; }
.slider { background: #536864; }
input:checked + .slider { background: #77994a; }
.betting-section { padding: 0; background: none; border: 0; border-radius: 0; }
.betting-header { flex-wrap: wrap; }
.betting-header > label { display: none !important; }
.balance-display, .odds-display-container { background: #203b3f; color: #d2e7ba; border: 1px solid #46605f; box-shadow: none; font-size: 12px; }
.bet-tabs { gap: 5px; }
.bet-tab { min-height: 44px; border: 1px solid #405c61; border-radius: 7px; padding: 8px; font-size: 12px; color: #becfc7; background: #21383f; flex: 1; }
.bet-tab.active { background: #d5ef96; color: #213a29; box-shadow: none; border-color: #d5ef96; }
.bet-description { color: #aebfb7; font-size: 12px; background: transparent; }
.quick-amount-btn { min-height: 44px; border-radius: 7px; font-size: 11px; border-color: #476266; box-shadow: none; }
.place-bet-button { background: #bfdcb0; color: #213c2c; border-radius: 8px; box-shadow: none; min-height: 44px; }
.modal-content, .settings-form, .help-modal-content, .menu-modal-content { scrollbar-width: thin; scrollbar-color: #657c72 transparent; }
.settings-form::-webkit-scrollbar, .help-modal-content::-webkit-scrollbar { display: block !important; width: 5px !important; }
.settings-form::-webkit-scrollbar-thumb, .help-modal-content::-webkit-scrollbar-thumb { background: #657c72; border-radius: 5px; }
.race-track.has-race-scene { padding-top: 22px; }
.broadcast-controls button { min-height: 44px; border-radius: 7px; }
.broadcast-controls button[aria-pressed=true]:hover { background: #d5ef96; color: #1b3328; }
.broadcast-heading .timer { font-size: 20px; }
.position-card { min-height: 66px; border-radius: 10px; }
.position-name { color: #e3eee0; }
@media (max-width: 760px) {
  .site-header { padding-left: 14px; padding-right: 14px; }
  #fpsCounter { right: 70px; }
  .logo { padding-right: 92px; }
  .logo-divider { margin: 0 9px; }
  .neon-text-alt { font-size: 12px; }
  .hero { grid-template-columns: 1fr; gap: 38px; padding: 43px 24px 42px; min-height: 0; }
  .hero h1 { font-size: clamp(32px,7.8vw,49px); margin-bottom: 18px; }
  .hero-eyebrow { font-size: 11px; margin-bottom: 17px; }
  .hero-description { font-size: 14px; line-height: 1.8; margin-bottom: 23px; max-width: 480px; }
  .hero-art { max-width: 530px; width: 100%; transform: none; box-shadow: none; }
  .hero-art img { max-height: 230px; object-fit: contain; }
  .preview-heading, .preview-caption { padding: 13px 18px; }
  .hero-facts { font-size: 10px; gap: 13px; margin-top: 18px; }
  .features { padding: 0 24px 32px; }
  .feature-container { grid-template-columns: 1fr; }
  .feature-card, .feature-card + .feature-card { padding: 22px 0; border-bottom: 1px solid #30454b; }
  .feature-number { float: left; margin: 4px 20px 0 0; }
  .feature-card h3 { font-size: 15px; }
  .feature-card p { padding-left: 34px; font-size: 12px; }
  .broadcast-heading .timer { font-size: 17px; }
  .race-track.has-race-scene { padding-top: 16px; }
  .positions-heading h3 { font-size: 15px; }
}
@media (max-width: 480px) {
  #settingsModal { padding: 10px; padding-top: max(10px,env(safe-area-inset-top,0px)); }
  #settingsModal .modal-header { padding: 13px 18px; }
  .settings-intro { padding: 15px 18px 0; font-size: 12px; }
  .settings-basics { padding: 18px 18px 0; }
  .settings-disclosure { margin: 0 18px; }
  .settings-actions { padding: 12px 18px max(12px,env(safe-area-inset-bottom,0px)); }
  .horse-names-container { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
  .count-step { width: 44px; flex-basis: 44px; }
  .range-slider-container { gap: 8px; }
  .range-value { min-width: 48px; }
  .count-presets button { min-width: 45px; }
  .modal-content, .menu-modal-content, .help-modal-content, .credits-content { padding: 18px; }
  .modal-header, .menu-modal-header, .help-modal-header, .credits-header { top: -18px; }
}


/* Mobile-first polish: keep controls reachable and reduce GPU work on phones. */
:is(.close-modal,.close-modal-button,.back-button) {
  display: grid;
  place-items: center;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
}

.menu-button,
.help-category-button,
.language-option-large {
  min-height: 48px;
}

#fpsCounter {
  display: none;
  pointer-events: none;
}

@media (max-width: 760px) {
  .site-header {
    gap: 10px;
    padding-left: max(14px, env(safe-area-inset-left, 0px));
    padding-right: max(14px, env(safe-area-inset-right, 0px));
  }

  .logo {
    flex: 1 1 auto;
    padding-right: 0;
    overflow: hidden;
  }

  #fpsCounter {
    top: calc(var(--header-clearance) + 8px);
    right: max(10px, env(safe-area-inset-right, 0px));
    width: auto;
    min-width: 58px;
    opacity: .82;
  }

  .modal,
  .main-menu-modal,
  .game-help-modal,
  .credits-modal,
  .race-results {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }

  .main-menu-modal,
  .game-help-modal,
  .credits-modal,
  .modal {
    background: rgba(4, 12, 16, .9);
  }
}

@media (max-width: 480px) {
  .main-menu-modal,
  .game-help-modal,
  .credits-modal {
    padding: max(12px, env(safe-area-inset-top, 0px)) max(12px, env(safe-area-inset-right, 0px)) max(12px, env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px));
  }

  .menu-modal-content,
  .help-modal-content,
  .credits-content {
    width: 100%;
    max-height: 100%;
    margin: 0;
    padding: 16px;
  }

  :is(.menu-modal-header,.help-modal-header,.credits-header) { top: -16px; margin: -4px 0 16px; padding: 12px 0; gap: 8px; }
  .help-modal-header .back-button { margin-right: 0; }
}

@media (max-width: 360px) {
  .logo > a:first-child,
  .logo-divider {
    display: none;
  }

  .neon-text-alt {
    font-size: 11.5px;
  }
}

/* Short landscape screens need room for the game between fixed controls. */
@media (orientation: landscape) and (max-height: 500px) {
  :is(#diceModal,#quickBetModal) .modal-content .modal-header { padding: 8px 16px; }
  :is(#diceModal,#quickBetModal) .modal-content .modal-header h2 { font-size: 18px; }
  :is(#diceModal .dice-actions,#quickBetModal .quickbet-actions) {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 6px 8px;
    padding: 8px 16px max(8px, env(safe-area-inset-bottom, 0px));
  }
  :is(#diceModal .dice-actions,#quickBetModal .quickbet-actions) > button { min-height: 44px; padding: 8px 12px; font-size: 12px; }
  :is(#dice-roll,#quickbet-start,.dice-actions .dice-hint,.quickbet-actions .quickbet-hint) { grid-column: 1 / -1; }
}

/* ---- css/modules/party.css ---- */
/* Room UI uses the existing modal and needs no animation loop. */
#partyModal [hidden] { display: none !important; }
#partyModal { padding: max(12px, env(safe-area-inset-top, 0px)) 12px max(12px, env(safe-area-inset-bottom, 0px)); }
#partyModal .party-panel { width: 100%; max-width: 560px; max-height: calc(100vh - 48px); max-height: calc(100dvh - 48px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)); margin: 12px auto; padding: 0; overflow-y: auto; overscroll-behavior: contain; animation: none; transform: none; transition: none; }
#partyModal .modal-header { position: sticky; top: 0; z-index: 2; gap: 16px; margin: 0; padding: 16px 20px; border-radius: 18px 18px 0 0; }
#partyModal .modal-header h2 { font-size: 21px; line-height: 1.4; }
#party-close { flex: 0 0 44px; width: 44px; height: 44px; padding: 0; background: #21373b; line-height: 1; }
.party-content { padding: 20px; }
.party-intro, .party-hint { color: #afc3bd; font-size: 13px; line-height: 1.7; overflow-wrap: anywhere; }
.party-intro { margin: 0 0 22px; }
.party-hint { margin: 10px 0 0; font-size: 12px; }
.party-field { margin-bottom: 18px; }
.party-field label, .party-link-label { display: block; margin: 0 0 8px; color: #e1ecdf; font-size: 13px; font-weight: 600; }
#partyModal input, #partyModal select { display: block; width: 100%; min-width: 0; min-height: 48px; padding: 12px; color: #f0f3e9; background: #11262d; border: 1px solid #4a6264; border-radius: 9px; font: inherit; font-size: 16px; box-shadow: none; }
#partyModal input:focus-visible, #partyModal select:focus-visible { border-color: #d5ef96; outline: 2px solid #d5ef96; outline-offset: 2px; }
#party-code { text-transform: uppercase; letter-spacing: .14em; font-variant-numeric: tabular-nums; }
.party-join-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 10px; margin-top: 24px; padding-top: 22px; border-top: 1px solid #3d5559; }
.party-join-row .party-field { margin: 0; }
#partyModal button { min-height: 44px; white-space: normal; word-break: normal; }
#partyModal .btn-primary, #partyModal .btn-secondary { padding: 12px 16px; font-size: 14px; }
#partyModal button:disabled { opacity: .45; }
#party-create { width: 100%; }
.party-notice, #party-error { border: 1px solid #526462; border-radius: 10px; padding: 12px 14px; color: #d6e2d4; background: #213a3e; font-size: 13px; line-height: 1.7; }
.party-notice { margin: 0 0 20px; }
#party-error { margin: 18px 0 0; border-color: #a58468; color: #ffdcbd; background: #372f29; }
#party-error:empty { display: none; }
.party-room-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.party-room-label { color: #a8bfb4; font-size: 11px; font-weight: 600; letter-spacing: .04em; }
#party-room-code { display: block; color: #d5ef96; font: 700 clamp(22px, 6vw, 30px)/1.35 ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .15em; }
#party-copy { max-width: 45%; font-size: 12px !important; }
#party-link { margin-top: 10px; font-size: 13px !important; }
.party-room-status { margin: 20px 0 0; padding: 16px; border: 1px solid #3f595b; border-radius: 12px; background: #20383e; }
#party-round-label { color: #b3c89e; font-size: 11px; font-weight: 600; }
#party-status { margin: 6px 0 0; color: #f0f3e9; font-size: 17px; font-weight: 700; line-height: 1.5; }
#party-connection { min-height: 1.7em; margin: 8px 0 0; color: #a5bbb5; font-size: 11px; line-height: 1.7; }
.party-section-heading { margin: 23px 0 11px; color: #dbe7d6; font-size: 13px; }
#party-players, #party-results { display: grid; gap: 7px; margin: 0; padding: 0; list-style: none; }
#party-players { max-height: 216px; overflow-y: auto; overscroll-behavior: contain; }
.party-player, .party-result { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-width: 0; padding: 11px 12px; border: 1px solid #3d5457; border-radius: 9px; background: #162c33; }
.party-player.is-self { border-color: #829c77; }
.party-player-info { flex: 1; min-width: 0; }
.party-player-meta { color: #b3c4bc; font-size: 11px; line-height: 1.6; }
.party-badge { flex-shrink: 0; max-width: 40%; }
.party-player-name { min-width: 0; flex: 1; color: #e7eddf; font-size: 14px; overflow-wrap: anywhere; }
.party-player-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin-top: 4px; }
.party-badge { display: inline-block; padding: 2px 6px; border-radius: 4px; background: #30494c; color: #bdcfbf; font-size: 10px; font-weight: 600; line-height: 1.6; }
.party-badge.is-ready { background: #354d39; color: #d5ef96; }
.party-player-state { flex-shrink: 0; max-width: 40%; color: #b3c4bc; font-size: 11px; line-height: 1.6; text-align: right; }
.party-player-state.is-ready { color: #d5ef96; }
.party-dice-area { margin-top: 22px; text-align: center; }
#party-dice { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; max-width: 344px; margin: 0 auto; padding: 12px 0; }
#party-dice > span { display: grid; place-items: center; flex: 0 0 76px; width: 76px; height: 76px; border-radius: 17px; background: #ecf0dd; color: #243d32; border: 1px solid #f7f8eb; box-shadow: 0 5px 0 #688477; font: 700 34px/1 ui-monospace, SFMono-Regular, Consolas, monospace; }
#party-dice.is-rolling > span { animation: party-dice-roll .45s ease-in-out 2; }
#party-dice.is-rolling > span:nth-child(2) { animation-delay: .06s; }
#party-dice.is-rolling > span:nth-child(3) { animation-delay: .12s; }
#party-dice.is-rolling > span:nth-child(4) { animation-delay: .18s; }
.party-result { padding: 12px; }
.party-result.is-winner { background: #2b4135; border-color: #a6c17f; }
.party-result-rank { flex: 0 0 42px; color: #b8ccaa; font-size: 12px; font-weight: 600; }
.party-result-score { flex-shrink: 0; max-width: 38%; overflow-wrap: anywhere; text-align: right; color: #d5ef96; font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }
.party-actions { display: grid; gap: 8px; margin-top: 22px; }
.party-actions > button { width: 100%; }
#party-ready[aria-pressed="true"] { color: #d5ef96; border-color: #abc786; background: #2a4236; }
.party-footer { border-top: 1px solid #3c5357; margin-top: 20px; padding-top: 16px; }
#party-leave { width: 100%; border-color: #48605e; color: #b3c7bd; font-size: 12px; }
@keyframes party-dice-roll { 0%, 100% { transform: rotate(0) translateY(0); } 25% { transform: rotate(-9deg) translateY(-5px); } 75% { transform: rotate(9deg) translateY(-3px); } }
@media (max-width: 380px) { .party-content { padding: 16px; } #partyModal .modal-header { padding: 14px 16px; } .party-join-row { grid-template-columns: 1fr; } #party-join { width: 100%; } .party-room-top { align-items: flex-start; } #party-room-code { letter-spacing: .08em; } }
@media (prefers-reduced-motion: reduce) { #party-dice.is-rolling > span { animation: none; } }

/* The confirmed rule stays visible while the host edits the next choice. */
.party-rules { margin-top: 18px; padding: 14px; border: 1px solid #3f595b; border-radius: 12px; background: #182f35; }
#party-rules-summary { margin: 0; color: #d5ef96; font-size: 14px; font-weight: 700; line-height: 1.5; overflow-wrap: anywhere; }
#party-rule-description { margin-top: 7px; }
#party-rule-controls { min-width: 0; margin: 15px 0 0; padding: 14px 0 0; border: 0; border-top: 1px solid #3d5559; }
#party-rule-controls legend { padding: 0 8px 0 0; color: #dbe7d6; font-size: 12px; font-weight: 600; }
.party-rule-fields { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 12px; }
.party-rule-fields .party-field { min-width: 0; margin-bottom: 0; }
#partyModal .party-rule-fields select { min-height: 46px; padding: 10px 8px; cursor: pointer; color-scheme: dark; }
#partyModal .party-rule-fields select:disabled { opacity: .6; cursor: default; }
#party-apply-rules { width: 100%; margin-top: 12px; }
#party-rules-notice { min-height: 1.7em; }
@media (max-width: 410px) {
  .party-rule-fields { grid-template-columns: 1fr; gap: 14px; }
  #party-dice { max-width: 164px; }
  .party-result { gap: 8px; padding: 11px 9px; }
  .party-result-rank { flex-basis: 36px; }
  .party-result-score { font-size: 14px; }
}

/* ---- css/modules/results-ui.css ---- */
/* One scrollable result body keeps the title and next-race action in reach. */
body.results-open #raceResults {
  display: flex !important;
  flex-direction: column;
  gap: 20px;
}

#raceResults {
  width: min(680px, calc(100% - 32px));
  padding: 24px;
  overflow: hidden;
  background: #101d24;
  border: 1px solid #31454b;
  box-shadow: 0 20px 70px #0006;
  text-align: left;
}

#raceResults > h2 {
  flex: 0 0 auto;
  margin: 0;
  color: #f0f6ee;
  font-size: clamp(1.4rem, 4.5vw, 1.75rem);
  line-height: 1.3;
  letter-spacing: -.025em;
  text-shadow: none;
}

#raceResults #results {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  margin: 0;
  padding: 0 6px 0 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y pinch-zoom;
  scrollbar-width: thin;
  scrollbar-color: #526665 transparent;
}

#raceResults #results::-webkit-scrollbar { display: block; width: 4px; }
#raceResults #results::-webkit-scrollbar-thumb { background: #526665; border-radius: 4px; }

/* Neutralize the old descendant-div card rule, including its hover transform. */
#raceResults #results div {
  padding: 0;
  margin: 0;
  border: 0;
  background: none;
  border-radius: 0;
  box-shadow: none;
  transform: none;
  transition: none;
}

#raceResults .result-winner {
  display: flex;
  align-items: center;
  gap: 18px;
  margin: 0 0 18px;
  padding: 22px;
  background: #25332e;
  border: 1px solid #55634a;
  border-radius: 14px;
}

#raceResults .result-winner-icon {
  display: grid;
  place-items: center;
  flex: 0 0 64px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #3c4630;
  font-size: 2.2rem;
}

#raceResults .result-winner-copy { min-width: 0; }
#raceResults .result-winner-label { margin: 0 0 5px; color: #ead58b; font-size: .75rem; font-weight: 700; letter-spacing: .03em; }
#raceResults .result-winner-name { margin: 0; color: #f5f7ed; font-size: clamp(1.3rem, 5vw, 1.8rem); line-height: 1.25; overflow-wrap: anywhere; }
#raceResults .result-winner-time { margin: 7px 0 0; color: #c4d1c7; font-size: .88rem; font-variant-numeric: tabular-nums; }
#raceResults .result-finish-count { margin: 0 0 12px; color: #9bb0ad; font-size: .8rem; }

#raceResults .race-results-list {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: .875rem;
}

#raceResults .race-results-header {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  border: 0;
}

#raceResults .race-results-list th,
#raceResults .race-results-list td {
  padding: 13px 10px;
  border-bottom: 1px solid #2b3e44;
  vertical-align: middle;
  line-height: 1.45;
}

#raceResults .race-results-list th {
  color: #9bb0ad;
  background: #182a31;
  font-size: .72rem;
  font-weight: 500;
  text-align: left;
}

#raceResults .race-results-list th:first-child { width: 70px; border-radius: 7px 0 0 7px; }
#raceResults .race-results-list th:last-child { width: 118px; border-radius: 0 7px 7px 0; text-align: right; }
#raceResults .result-position { color: #9bb0ad; font-variant-numeric: tabular-nums; white-space: nowrap; }
#raceResults .race-results-list td.result-participant { position: relative; padding-left: 28px; color: #edf3ed; }
#raceResults .result-color { position: absolute; top: calc(50% - 4px); left: 10px; width: 5px; height: 8px; border-radius: 3px; }
#raceResults .result-horse { display: block; min-width: 0; overflow-wrap: anywhere; word-break: normal; }
#raceResults .result-time { color: #c3d1ca; text-align: right; white-space: nowrap; font-size: .82rem; font-variant-numeric: tabular-nums; }
#raceResults .gold-medal .result-position { color: #ead58b; font-weight: 700; }
#raceResults .silver-medal .result-position { color: #d6e0e3; font-weight: 700; }
#raceResults .bronze-medal .result-position { color: #d4b095; font-weight: 700; }
#raceResults .race-result-item:last-child td { border-bottom: 0; }

#raceResults .betting-results-header { margin: 24px 0 10px; padding: 0; border: 0; color: #edf3ed; font-size: 1rem; text-align: left; }
#raceResults #results .betting-results-container { padding: 0 14px; border: 1px solid #31454b; border-radius: 10px; background: #182a31; }
#raceResults #results .bet-result { padding: 12px 0; border-bottom: 1px solid #31454b; font-size: .8rem; line-height: 1.6; overflow-wrap: anywhere; }
#raceResults #results .bet-result.win { color: #d5ef96; }
#raceResults #results .bet-result.loss { color: #a6b8b6; }
#raceResults #results .bet-total { padding: 14px 0 5px; color: #d5ef96; font-size: .85rem; }
#raceResults #results .bet-total.loss { color: #b6c8c3; }
#raceResults #results .balance-display { padding: 0 0 14px; color: #b6c8c3; font-size: .8rem; }

#raceResults #newRaceBtn {
  flex: 0 0 auto;
  position: relative;
  bottom: auto;
  width: 100%;
  min-height: 50px;
  margin: 0;
  padding: 12px 18px;
  border: 0;
  border-radius: 10px;
  background: #d5ef96;
  color: #182617;
  box-shadow: none;
  font-weight: 700;
  text-shadow: none;
}

#raceResults #newRaceBtn:hover { background: #e2f5b9; transform: none; box-shadow: none; }
#raceResults #newRaceBtn:focus-visible { outline: 2px solid #d5ef96; outline-offset: 4px; }

@media (max-width: 480px) {
  body.results-open #raceResults { gap: 16px; }
  #raceResults { width: calc(100% - 24px); padding: 18px 16px; }
  #raceResults .result-winner { padding: 16px; gap: 14px; }
  #raceResults .result-winner-icon { flex-basis: 48px; width: 48px; height: 48px; font-size: 1.8rem; }
  #raceResults .race-results-list th, #raceResults .race-results-list td { padding: 12px 5px; }
  #raceResults .race-results-list th:first-child { width: 54px; }
  #raceResults .race-results-list th:last-child { width: 90px; }
  #raceResults .race-results-list td.result-participant { padding-left: 22px; }
  #raceResults .result-color { left: 3px; }
  #raceResults .result-time { font-size: .75rem; }
  #raceResults .result-horse { font-size: .8rem; }
}

#raceResults .result-extras { margin: 0 0 16px; }
#raceResults .result-finish-note { margin: 0 0 10px; padding: 10px 12px; border-left: 3px solid #d5ef96; background: #1c3031; color: #dceab8; font-size: .8rem; line-height: 1.6; overflow-wrap: anywhere; }
#raceResults .result-copy-btn { min-height: 44px; padding: 8px 16px; border: 1px solid #536962; border-radius: 8px; background: #203537; color: #e5efdf; font: inherit; font-size: .8rem; cursor: pointer; }
#raceResults .result-copy-btn:disabled { opacity: .5; cursor: wait; }
#raceResults .result-copy-status { margin: 8px 0 0; font-size: .75rem; line-height: 1.6; color: #b9cebd; }
#raceResults .result-copy-status:empty { margin: 0; }
#raceResults .result-copy-text { box-sizing: border-box; width: 100%; margin-top: 10px; padding: 10px; border: 1px solid #526962; border-radius: 8px; background: #15282d; color: #e5efdf; font: 16px/1.5 system-ui, sans-serif; resize: vertical; }

/* ---- css/modules/themes.css ---- */
/* Compact theme previews use CSS only; full scenery stays on the race canvas. */
.theme-picker { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 9px; }
.theme-choice { position: relative; min-width: 0; padding: 8px; border: 1px solid #405c61; border-radius: 10px; color: #e2e9dc; background: #172d34; text-align: left; overflow: hidden; }
.theme-choice:hover { border-color: #96b283; background-color: #243d40; }
.theme-choice[aria-pressed=true] { border-color: #d5ef96; box-shadow: inset 0 0 0 1px #d5ef96; }
.theme-choice[aria-pressed=true] .theme-choice-name { color: #d5ef96; }
.theme-random { grid-column: 1 / -1; min-height: 44px; display: flex; gap: 9px; align-items: center; padding: 10px 13px; font-size: 12px; }
.theme-random > span:first-child { font-size: 21px; line-height: 1; color: #d5ef96; }
.theme-swatch { display: block; width: 100%; height: 52px; border-radius: 7px; margin-bottom: 7px; border: 1px solid rgba(255, 255, 255, 0.12); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18); }
.theme-meadow .theme-swatch { background: radial-gradient(circle at 78% 26%, #fff3b8 0 8px, rgba(255, 244, 190, 0.28) 9px 14px, transparent 15px), linear-gradient(162deg, transparent 46%, #549675 47% 64%, #619866 65% 82%, #c69a6e 83%), linear-gradient(180deg, #4f96b8 0%, #92cad8 52%, #d8ebd2 100%); }
.theme-coast .theme-swatch { background: radial-gradient(circle at 78% 24%, #fff3c0 0 7px, rgba(255, 245, 198, 0.25) 8px 13px, transparent 14px), radial-gradient(ellipse at 68% 54%, #3f7272 0 16px, transparent 17px), linear-gradient(176deg, #3e8fb9 0 38%, #2a829c 39% 54%, #429faf 55% 72%, #68b9ad 73% 81%, #f0dcaa 82%); }
.theme-desert .theme-swatch { background: radial-gradient(circle at 74% 32%, #ffd699 0 10px, rgba(255, 214, 150, 0.25) 11px 17px, transparent 18px), linear-gradient(168deg, transparent 52%, #b06d66 53% 68%, #dd9f78 69% 84%, #bf8f6b 85%), linear-gradient(180deg, #4f355c 0%, #9c566d 48%, #df8863 78%, #f7c38a 100%); }
.theme-city .theme-swatch { background: repeating-linear-gradient(90deg, transparent 0 14px, #202d46 15px 28px, #273952 29px 39px, transparent 40px 44px) center bottom / 100% 30px no-repeat, radial-gradient(circle at 79% 25%, #eceac8 0 6px, rgba(216, 228, 255, 0.16) 7px 11px, transparent 12px), linear-gradient(180deg, #101733 0%, #243154 54%, #3d375b 84%, #4f6d7d 100%); border-bottom: 2px solid #66d2d4; }
.theme-choice-name, .theme-choice-mood { display: block; }
.theme-choice-name { font-size: 12px; font-weight: 650; line-height: 1.5; }
.theme-choice-mood { font-size: 10px; color: #9eb6af; margin-top: 2px; line-height: 1.5; }
.theme-hint { margin: 12px 0 5px; font-size: 11px; }
.theme-track-title { font-size: 11px; color: #c5d8ae; }
.site-header .music-toggle { position: absolute; top: calc(12px + env(safe-area-inset-top,0px)); right: 78px; width: 44px; height: 44px; border: 1px solid #405258; border-radius: 10px; color: #d5ef96; background: #1b3035; font-size: 20px; white-space: nowrap; }
.site-header .music-toggle[aria-pressed=false] { color: #92a6a7; font-size: 16px; }
#fpsCounter { right: calc(132px + env(safe-area-inset-right,0px)); width: 65px; }
.logo { padding-right: 164px; }
.music-settings { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; gap: 10px; padding-bottom: 20px; }
.music-settings label { grid-column: 2 / -1; font-size: 12px; }
.music-toggle-inline { grid-row: 1 / 3; width: 44px; height: 44px; border: 1px solid #4a6264; border-radius: 9px; background: #203a3e; color: #d5ef96; font-size: 20px; }
.music-settings input { grid-column: 2; }
.music-settings output { font-size: 12px; color: #cadab9; text-align: right; }
.music-credits { padding: 15px 0 18px; border-top: 1px solid #3d5559; font-size: 11px; color: #9fb4b2; }
.music-credits h3 { font-size: 12px; color: #dce5d3; margin-bottom: 8px; }
.music-credits ul { padding: 10px 0 10px 18px; }
.music-credits li { margin-bottom: 4px; }
.music-credits a { color: #c6dca9; text-underline-offset: 3px; }
@media (max-width: 760px) {
  .site-header .music-toggle { right: 68px; }
  #fpsCounter { right: 120px; width: 59px; font-size: 10px; }
  .logo { padding-right: 136px; }
  .neon-text-alt { max-width: 160px; }
}
@media (max-width: 360px) {
  .logo-divider { margin: 0 5px; }
  .neon-text-alt { font-size: 11px; }
  .theme-choice-mood { font-size: 9px; }
}

/* ---- css/modules/home.css ---- */
/* A bright game shelf. The portal is scoped; race and settings keep their own palette. */
body.game-portal { background:#f7f9ff; }
.game-portal .site-header { padding-inline:max(24px,calc((100vw - 1200px)/2)); background:#fff; border-bottom:1px solid #e4e8f2; gap:12px; }
.game-portal .logo { flex:1; min-width:0; padding:0; }
.game-portal .home-brand { display:flex; align-items:center; gap:10px; }
.game-portal .neon-text { font-size:26px; transition:none; }
.game-portal .neon-text-alt { color:#25344e; font-size:16px; font-weight:800; letter-spacing:-.04em; transition:none; }
.game-portal .site-header .music-toggle { position:static; flex:0 0 42px; width:42px; height:42px; border:1px solid #dce2ef; border-radius:12px; background:#f5f7fc; color:#3158bd; }
.game-portal #hamburgerBtn { position:static; min-width:108px; height:42px; padding:0 13px; background:#edf2ff; border-color:#d4dffb; color:#244db0; }
.game-portal #hamburgerBtn .hamburger-line { background:#3158bd; }
.game-portal #hamburgerBtn .menu-trigger-label { color:#244db0; }
.game-portal #hamburgerBtn:hover { background:#dfe8ff; border-color:#a8beee; }
.game-portal .site-header :is(a,button):focus-visible { outline:3px solid #315de1; outline-offset:3px; }
/* Diagnostics stay below navigation at every width, including the centered desktop header. */
.game-portal #fpsCounter { top:calc(var(--header-clearance) + 8px); right:max(12px,env(safe-area-inset-right,0px)); }
.hero.game-home {
  --home-ink:#25344e; --home-muted:#59667c; --home-paper:#f7f9ff; --home-blue:#315de1;
  display:block; height:auto; min-height:0; overflow:visible; color-scheme:light;
  padding:30px max(24px,calc((100vw - 1200px)/2)) 58px;
  background:var(--home-paper); color:var(--home-ink); text-align:left;
}
.home-welcome { display:grid; grid-template-columns:1fr 1.08fr; align-items:center; gap:34px; padding:32px 36px; margin-bottom:42px; border-radius:26px; background:#eaf0ff; }
.home-intro { min-width:0; }
.game-home .hero-eyebrow { margin:0 0 12px; font-size:13px; font-weight:700; letter-spacing:0; color:#48609a; }
.game-home h1 { color:var(--home-ink); font-size:clamp(32px,3.4vw,44px); line-height:1.2; font-weight:850; letter-spacing:-.055em; white-space:pre-line; text-wrap:balance; margin:0 0 16px; }
.game-home .hero-description { color:#52627e; font-size:14px; line-height:1.75; max-width:440px; margin:0; word-break:keep-all; overflow-wrap:anywhere; }
.home-browse-link { display:inline-flex; align-items:center; gap:20px; min-height:44px; margin-top:18px; padding:10px 16px; border-radius:10px; text-decoration:none; font-size:13px; font-weight:750; background:#315de1; color:white; }
.home-browse-link:hover { background:#244bc0; }
.home-browse-link svg { width:18px; height:18px; }
.game-home .hero-facts { margin-top:14px; font-size:11px; color:#566889; gap:16px; }
.game-home .hero-facts span::before { color:#315de1; }
.home-featured { position:relative; display:grid; grid-template-columns:48% 1fr; align-self:stretch; align-items:stretch; overflow:hidden; min-width:0; background:#fff; border:1px solid #d7e0f3; border-radius:20px; }
.home-game-art { position:relative; overflow:hidden; min-width:0; contain:paint; }
.home-featured .home-race-art { height:100%; min-height:224px; background:#a4d4c8; }
.home-race-scene { display:block; width:100%; height:100%; }
.home-featured-copy { display:flex; flex-direction:column; align-items:flex-start; justify-content:center; gap:8px; padding:24px 20px; min-width:0; }
.home-featured-label { color:#475fc1; background:#edf1ff; padding:4px 9px; border-radius:6px; font-size:11px; font-weight:750; }
.home-featured h2 { color:#25344e; margin:0; font-size:24px; font-weight:800; letter-spacing:-.045em; line-height:1.35; word-break:keep-all; overflow-wrap:anywhere; }
.home-featured-copy > p { color:#59667c; font-size:12px; line-height:1.7; margin:0; word-break:keep-all; overflow-wrap:anywhere; }
.home-featured-actions { display:flex; align-items:center; gap:6px; flex-wrap:wrap; margin-top:8px; }
.home-featured-play { min-height:44px; border-radius:9px; background:#25344e; color:white; padding:10px 15px; font-family:inherit; font-size:13px; font-weight:700; line-height:1.5; border:1px solid #25344e; }
.home-featured-play:hover { background:#315de1; border-color:#315de1; }
.home-help-button { width:44px; min-height:44px; color:#435777; background:#fff; border:1px solid #ccd5e6; border-radius:9px; font:18px Georgia,serif; }
.home-help-button:hover { background:#eef2fc; }
.home-directory-heading { display:flex; align-items:flex-start; justify-content:space-between; gap:18px; margin-bottom:20px; }
.home-directory-heading h2 { font-size:25px; letter-spacing:-.045em; font-weight:800; margin:0 0 6px; color:var(--home-ink); }
.home-directory-heading p { color:var(--home-muted); font-size:13px; line-height:1.6; margin:0; }
.home-motion-toggle { position:static; display:inline-flex; align-items:center; gap:5px; flex-shrink:0; min-height:44px; padding:9px 11px; border:1px solid #d8dfec; border-radius:9px; background:#fff; color:#526079; font:12px/1.4 system-ui,sans-serif; }
.home-motion-toggle svg { width:16px; height:16px; }
.home-motion-toggle:hover { background:#eaf0ff; border-color:#b6c7ef; }
.home-motion-toggle[aria-pressed="true"] { color:#3157b9; background:#eaf0ff; }
.home-discovery { display:grid; grid-template-columns:minmax(0,1fr) 220px; gap:14px; margin-bottom:20px; }
.home-discovery label { display:block; font-size:12px; font-weight:700; line-height:1.5; color:#56647a; margin-bottom:7px; }
.home-search-control,.home-mode-control { min-width:0; }
.home-search-field { display:flex; align-items:center; gap:12px; height:50px; padding:0 4px 0 16px; border:1px solid #cbd5e7; border-radius:12px; background:#fff; color:#66758c; }
.home-search-field > svg { width:21px; height:21px; flex-shrink:0; }
.home-search-field:focus-within { border-color:#315de1; outline:3px solid #315de120; }
#home-search { min-width:0; width:100%; flex:1; padding:12px 0; border:0; border-radius:0; background:transparent; color:#25344e; box-shadow:none; outline:0; font-family:inherit; font-size:16px; line-height:1.5; }
#home-search::placeholder { color:#6b7890; opacity:1; }
#home-search::-webkit-search-cancel-button { -webkit-appearance:none; }
#home-search-clear { flex:0 0 44px; display:grid; place-items:center; width:44px; height:44px; color:#526079; border-radius:8px; }
#home-search-clear:hover { background:#eef2fb; }
#home-search-clear svg { width:18px; height:18px; }
#home-play-mode { width:100%; height:50px; padding:12px 36px 12px 14px; border:1px solid #cbd5e7; border-radius:12px; color:#344663; background:#fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9' viewBox='0 0 14 9'%3E%3Cpath d='m2 2 5 5 5-5' fill='none' stroke='%2359667c' stroke-width='1.8'/%3E%3C/svg%3E") no-repeat right 14px center; font-family:inherit; font-size:14px; }
.home-filter-row { display:flex; align-items:center; justify-content:space-between; gap:14px; border-bottom:1px solid #dce3f0; padding-bottom:18px; }
.home-filters { display:flex; flex-wrap:wrap; gap:7px; }
.home-filters button { display:inline-flex; align-items:center; justify-content:center; gap:7px; min-height:44px; padding:10px 15px; border:1px solid transparent; background:transparent; border-radius:10px; color:#59667c; font:650 13px/1.4 system-ui,sans-serif; transition:background .15s,color .15s; }
.home-filters button:hover { background:#e7edfb; }
.home-filters button[aria-pressed="true"] { color:#fff; background:#315de1; border-color:#315de1; }
.home-filter-count { font-size:11px; font-weight:500; font-variant-numeric:tabular-nums; }
#home-catalog-status { font-size:12px; color:#59667c; white-space:nowrap; font-variant-numeric:tabular-nums; }
.home-category { margin-top:30px; }
.home-category-heading { display:flex; align-items:baseline; gap:14px; margin-bottom:15px; }
.home-category-heading h3 { color:#25344e; font-size:18px; font-weight:800; letter-spacing:-.025em; margin:0; }
.home-category-heading h3::before { content:''; display:inline-block; width:8px; height:8px; border-radius:3px; background:#315de1; margin-right:8px; vertical-align:2px; }
[data-home-group="challenge"] h3::before { background:#d48254; }
[data-home-group="board"] h3::before { background:#8b70ca; }
[data-home-group="online"] h3::before { background:#25887b; }
.home-category-heading p { color:#667288; font-size:12px; line-height:1.6; margin:0; }
.home-game-grid { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:18px; }
.home-tile { position:relative; display:flex; flex-direction:column; min-width:0; width:100%; padding:0; margin:0; color:#25344e; border:1px solid #e0e5ef; border-radius:16px; background:#fff; text-align:left; text-decoration:none; font-family:inherit; overflow:hidden; box-shadow:none; transition:border-color .16s,box-shadow .16s; }
.home-tile:hover { border-color:#9ab1ea; box-shadow:0 5px 18px #35558d12; background:#fff; }
.home-tile-art { position:relative; display:grid; place-items:center; width:100%; height:124px; background:#e3edd8; overflow:hidden; }
.home-tile-art > svg { display:block; height:104px; width:134px; }
.home-tile-copy { display:flex; flex-direction:column; flex:1; min-width:0; padding:17px 17px 15px; }
.home-tile-title { display:block; font-size:17px; line-height:1.45; font-weight:800; letter-spacing:-.035em; padding-right:18px; word-break:keep-all; overflow-wrap:anywhere; }
.home-tile-desc { display:block; font-size:13px; line-height:1.65; color:#5e6b80; margin:7px 0 16px; word-break:keep-all; overflow-wrap:anywhere; }
.home-tile-meta { display:block; color:#53647b; font-size:11px; line-height:1.6; margin-top:auto; padding-top:10px; border-top:1px solid #edf0f6; font-weight:600; }
.home-tile-open { position:absolute; right:15px; top:143px; font-size:16px; color:#6a7da5; }
.hero.game-home :is(a,button,input,select):focus-visible { outline:3px solid #315de1; outline-offset:3px; }
.hero.game-home #home-search:focus-visible { outline:none; } /* The complete field has a visible focus-within ring. */
:lang(ja) .game-home :is(h1,.home-tile-title,.home-tile-desc) { word-break:normal; line-break:strict; }
.home-empty-state { padding:56px 18px; text-align:center; color:#65748c; }
.home-empty-state > svg { width:48px; height:48px; margin-bottom:16px; color:#92a4cd; }
.home-empty-state h3 { color:#344663; font-size:20px; margin:0 0 8px; }
.home-empty-state p { font-size:14px; margin:0 0 20px; }
#home-reset-filters { min-height:44px; padding:10px 16px; border-radius:10px; background:#315de1; color:#fff; font-size:14px; }
.home-category[hidden],.home-tile[hidden],.home-motion-toggle[hidden],#home-search-clear[hidden],.home-empty-state[hidden] { display:none; }
.features.home-guide { background:#edf2fc; padding:34px max(24px,calc((100vw - 1200px)/2)) 40px; }
.home-guide > h2 { color:#25344e; font-size:20px; font-weight:800; letter-spacing:-.03em; margin:0 0 16px; }
.home-guide .feature-container { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:14px; border-top:0; }
.home-guide .feature-card,.home-guide .feature-card + .feature-card { display:flex; flex-direction:column; align-items:flex-start; gap:6px; padding:20px 22px; background:#fff; border:1px solid #d8e2f3; border-radius:16px; box-shadow:none; transition:none; }
.home-guide .feature-card h3 { color:#25344e; font-size:16px; font-weight:800; line-height:1.35; margin:0; }
.home-guide .feature-card p { color:#59667c; font-size:13px; line-height:1.65; margin:0; padding:0; word-break:keep-all; }
.home-guide .feature-number { display:inline-flex; align-items:center; justify-content:center; min-width:30px; height:26px; padding:0 8px; margin:0 0 2px; float:none; border-radius:8px; background:#eaf0ff; font:800 12px/1 system-ui,sans-serif; color:#315de1; }
.game-portal .home-footer { display:flex; justify-content:space-between; align-items:center; flex-wrap:wrap; gap:16px; background:#fff; color:#65738b; border-top:1px solid #e2e8f4; padding:26px max(24px,calc((100vw - 1200px)/2)); }
.home-footer p { margin:0; }
.home-footer .locale-links { margin:0; }
.game-portal .home-footer a { color:#425d99; }
.game-portal .home-footer .locale-links a.active,
.game-portal .home-footer .locale-links a[aria-current="true"] {
  color:#244db0; font-weight:800; text-decoration:underline; text-underline-offset:4px;
}
.game-portal .home-footer .locale-links a:focus-visible {
  outline:3px solid #315de1; outline-offset:3px;
}
.home-footer-top { font-size:13px; font-weight:700; text-decoration:none; }
.home-skip-link { position:fixed; top:-100px; left:20px; z-index:10000; padding:12px 20px; background:#fff; color:#244db0; border:2px solid #315de1; border-radius:8px; text-decoration:none; font-size:14px; }
.home-skip-link:focus { top:calc(8px + env(safe-area-inset-top,0px)); }
#home-catalog { scroll-margin-top:calc(var(--header-clearance) + 18px); }
@media(min-width:1000px) { [data-home-group="online"] .home-game-grid { grid-template-columns:repeat(2,minmax(0,1fr)); } [data-home-group="online"] .home-tile { flex-direction:row; } [data-home-group="online"] .home-tile-art { width:34%; height:auto; min-height:164px; flex-shrink:0; } [data-home-group="online"] .home-tile-open { top:20px; } }
@media(min-width:601px) and (max-width:999px) { .home-game-grid { grid-template-columns:repeat(3,minmax(0,1fr)); } .home-welcome { gap:24px; padding:26px; grid-template-columns:1fr 1fr; } .home-featured { grid-template-columns:1fr; } .home-featured .home-race-art { min-height:130px; height:130px; } .home-featured-copy { padding:16px; } .home-featured h2 { font-size:21px; } .home-featured-copy > p { display:none; } }
@media(max-width:900px) {
  .home-guide .feature-container { grid-template-columns:1fr; gap:10px; border-top:0; }
  .home-guide .feature-card,.home-guide .feature-card + .feature-card { display:grid; grid-template-columns:34px minmax(0,1fr); column-gap:12px; row-gap:4px; align-items:start; padding:14px 16px; background:#fff; border:1px solid #d8e2f3; border-bottom:1px solid #d8e2f3; border-radius:14px; }
  .home-guide .feature-number { position:static; float:none; grid-column:1; grid-row:1 / 3; width:34px; height:34px; min-width:34px; margin:0; padding:0; border-radius:10px; background:#eaf0ff; color:#315de1; font-size:13px; font-weight:800; display:grid; place-items:center; }
  .home-guide .feature-card h3 { grid-column:2; grid-row:1; font-size:15px; line-height:1.35; margin:0; }
  .home-guide .feature-card p { grid-column:2; grid-row:2; font-size:12.5px; line-height:1.55; margin:0; padding:0; }
}
@media(max-width:800px) { .home-filter-row { flex-wrap:wrap; gap:12px; } .home-category-heading { display:block; } .home-category-heading p { margin-top:5px; } }
@media(max-width:600px) {
  .game-portal .site-header { padding-inline:14px; gap:8px; }
  .game-portal .home-brand { gap:6px; }
  .game-portal .neon-text { font-size:20px; }
  .game-portal .neon-text-alt { font-size:13px; }
  .game-portal #hamburgerBtn { min-width:38px; padding:0 10px; font-size:11px; }
  .game-portal .site-header .music-toggle { flex-basis:38px; width:38px; }
  .hero.game-home { padding:14px 14px 32px; }
  .home-welcome { display:block; padding:18px 16px 16px; border-radius:18px; margin-bottom:22px; }
  .game-home .hero-eyebrow { display:none; }
  .game-home h1 { font-size:clamp(22px,6.2vw,26px); line-height:1.24; margin-bottom:8px; }
  .game-home .hero-description { font-size:13px; line-height:1.6; max-width:none; }
  .home-browse-link,.game-home .hero-facts { display:none; }
  .home-featured { margin-top:14px; grid-template-columns:126px minmax(0,1fr); border-radius:14px; }
  .home-featured .home-race-art { min-height:114px; height:100%; }
  .home-featured-copy { padding:12px 14px; gap:5px; }
  .home-featured-label { padding:3px 7px; background:#edf1ff; font-size:10.5px; }
  .home-featured h2 { font-size:17px; line-height:1.3; }
  .home-featured-copy > p { display:none; }
  .home-featured-actions { gap:5px; margin-top:3px; }
  .home-featured-play { min-height:36px; padding:7px 13px; font-size:12px; white-space:nowrap; }
  .home-help-button { width:36px; min-height:36px; }
  .home-directory-heading { gap:10px; margin-bottom:12px; align-items:flex-start; }
  .home-directory-heading > div { min-width:0; flex:1; }
  .home-directory-heading h2 { font-size:19px; line-height:1.3; margin:0 0 3px; }
  .home-directory-heading p { display:block; font-size:12px; line-height:1.45; margin:0; }
  .home-motion-toggle { min-height:36px; font-size:11px; padding:6px 10px; border-radius:8px; }
  .home-motion-toggle svg { width:13px; height:13px; }
  .home-discovery { grid-template-columns:1fr; gap:10px; margin-bottom:14px; }
  .home-discovery label { font-size:11.5px; margin-bottom:4px; }
  .home-search-field { height:44px; gap:8px; padding:0 6px 0 12px; border-radius:10px; }
  .home-search-field > svg { width:17px; height:17px; }
  #home-search { font-size:15px; padding:8px 0; }
  #home-search-clear { flex-basis:34px; width:34px; height:34px; }
  #home-play-mode { height:44px; font-size:13.5px; padding:8px 32px 8px 12px; border-radius:10px; background-position:right 12px center; background-size:11px; }
  .home-filter-row { display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:8px; padding-bottom:12px; }
  .home-filters { flex-wrap:wrap; overflow-x:visible; gap:6px; padding-bottom:0; width:100%; }
  .home-filters button { flex:0 0 auto; white-space:nowrap; min-height:34px; font-size:12px; padding:6px 11px; gap:5px; border-radius:8px; border-color:var(--border-color,#d8e1f2); background:var(--bg-surface,#fff); }
  .home-filters button[aria-pressed="true"] { background:#315de1; border-color:#315de1; color:#fff; }
  .home-filter-count { font-size:10.5px; }
  #home-catalog-status { display:block; width:100%; margin-top:2px; font-size:11.5px; }
  .home-category { margin-top:20px; }
  .home-category-heading { margin-bottom:10px; }
  .home-category-heading h3 { font-size:16px; }
  .home-category-heading p { display:block; font-size:11.5px; margin-top:3px; }
  .home-game-grid { grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; }
  .home-tile { border-radius:13px; }
  .home-tile-art { height:88px; }
  .home-tile-art > svg { width:100px; height:80px; }
  .home-tile-copy { padding:10px 11px 10px; }
  .home-tile-title { font-size:14px; line-height:1.35; margin-right:18px; padding-right:0; }
  .home-tile-desc { font-size:11.5px; line-height:1.45; margin:4px 0 8px; display:-webkit-box; -webkit-box-orient:vertical; -webkit-line-clamp:2; overflow:hidden; }
  .home-tile-meta { font-size:10.5px; line-height:1.35; padding-top:7px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
  .home-tile-open { right:9px; top:98px; font-size:13px; line-height:1; }
  .features.home-guide { padding:24px 14px 28px; }
  .home-guide > h2 { font-size:18px; margin:0 0 12px; }
  .home-guide .feature-container { grid-template-columns:1fr; gap:10px; }
  .home-guide .feature-card,.home-guide .feature-card + .feature-card { padding:14px 15px; }
  .home-guide .feature-number { position:static; float:none; margin:0; }
  .home-guide .feature-card h3 { font-size:15px; margin:0; }
  .home-guide .feature-card p { font-size:12.5px; padding:0; margin:0; }
  .game-portal .home-footer { justify-content:center; padding:20px 16px; text-align:center; gap:10px 18px; }
  .home-footer p { order:3; width:100%; }
}
@media(max-width:359px) { .hero.game-home { padding-inline:12px; } .game-portal .site-header { padding-inline:10px; gap:5px; } .game-portal .neon-text-alt { font-size:12px; } .home-welcome { padding:16px 14px; } .game-home h1 { font-size:21px; } .home-directory-heading h2 { font-size:17.5px; } .home-discovery { grid-template-columns:1fr; } .home-search-field > svg { display:block; width:16px; height:16px; } .home-tile-copy { padding:9px 10px; } .home-tile-open { right:8px; top:97px; } }
@media(prefers-reduced-motion:reduce) { .home-tile,.home-filters button { transition:none; } }

/* Reused game artwork. */
/* Restore the original three-horse home scene for the race directory tile. */
.home-tile-race .home-tile-art { background: #9ccabb; }
.home-tile-race .home-tile-art > svg.home-race-tile-scene { width: 100%; height: 100%; animation: none; }
.home-tile-dice .home-tile-art { background: #f0e4d4; }
.home-tile-hwatu .home-tile-art { background: #eee3d9; }
.home-tile-roulette .home-tile-art { background: #e9e3f0; }
.home-tile-ladder .home-tile-art { background: #dfeae3; }
.home-tile-marble .home-tile-art { background: #e4f0e6; }
.home-tile-balloon .home-tile-art { background: #f3e5d9; }
.home-tile-cards .home-tile-art { background: #dde8ef; }
.home-tile-pirate .home-tile-art { background: #d9e8e4; }
.home-tile-pirate .home-pirate-person { animation: home-pirate-peek 3.6s ease-in-out infinite; transform-origin: 60px 56px; }
@keyframes home-pirate-peek { 0%,19%,76%,100% { transform: translateY(12px); } 32%,58% { transform: translateY(-5px) rotate(3deg); } }
@media (prefers-reduced-motion: reduce) { .home-tile-pirate .home-pirate-person {animation:none} }
.home-tile-bomb .home-tile-art { background: #dae6e5; }
.home-tile-reaction .home-tile-art { background: #e2ebd2; }
.home-tile-timer .home-tile-art { background: #ece5d3; }
.home-tile-chess .home-tile-art { background: #e0e5d7; }
.home-tile-janggi .home-tile-art { background: #eee3ce; }
.home-tile-omok .home-tile-art { background: #e3e8d9; }
.home-tile-yut .home-tile-art { background: #ece2ce; }
.home-tile-holdem .home-tile-art { background: #dce7dc; }
.home-game-art.home-dice-art { height: 100%; width: 100%; }
.home-die { position: absolute; display: grid; grid-template-columns: repeat(3,1fr); grid-template-rows: repeat(3,1fr); place-items: center; width: 59px; height: 59px; padding: 10px; border-radius: 13px; background: linear-gradient(145deg, #fffdf4, #ede5d0); border: 1.5px solid #fffbe8; box-shadow: inset 1px 2px 4px #ffffff, -4px 6px 0 #a87e64, 0 8px 14px rgba(42, 28, 18, 0.16); }
.home-die i { display: block; width: 8.5px; height: 8.5px; border-radius: 50%; background: #2d4239; box-shadow: inset 0 1px 1px rgba(0,0,0,0.35); }
.home-die-back { left: calc(50% - 54px); top: 19px; background: linear-gradient(145deg, #f3f7e3, #d7e2bd); box-shadow: inset 1px 2px 4px #ffffff, -4px 6px 0 #8fa17a, 0 6px 12px rgba(34, 48, 30, 0.14); }
.home-die-front { left: calc(50% + 2px); top: 32px; }
.home-die-back i:nth-child(1), .home-die-front i:nth-child(1) { grid-area: 1/1; }
.home-die-back i:nth-child(2), .home-die-front i:nth-child(2) { grid-area: 1/3; }
.home-die-back i:nth-child(3), .home-die-front i:nth-child(4) { grid-area: 3/1; }
.home-die-back i:nth-child(4), .home-die-front i:nth-child(5) { grid-area: 3/3; }
.home-die-front i:nth-child(3) { grid-area: 2/2; width: 10px; height: 10px; background: radial-gradient(circle at 35% 30%, #f05a54, #b82329 78%); }

/* Small, contained previews. HomeMotion only runs artwork in the visible page. */
.home-game-art { contain: paint; }
.home-die-back { --die-angle: -19deg; --toss-delay: -.6s; }
.home-die-front { --die-angle: 17deg; --toss-delay: -1.9s; }
.home-die-small { --die-angle: -14deg; --toss-delay: -3.4s; }
.home-game-art:not([data-motion="running"]) *,
body:is([data-performance="low"], [data-performance="ultraLow"], .low-performance-mode) .home-game-art * {
  animation-play-state: paused !important;
}
@media (prefers-reduced-motion: no-preference) {
  .home-race-bob { animation: home-race-gallop .72s ease-in-out infinite; animation-delay: var(--stride-delay, 0s); }
  .home-race-leg, .home-race-knee, .home-race-tail { transform-box: view-box; transform-origin: 0 0; }
  .home-race-leg { animation: home-race-stride .72s ease-in-out infinite; animation-delay: calc(var(--stride-delay, 0s) + var(--leg-phase, 0s)); }
  .home-race-knee { animation: home-race-knee .72s ease-in-out infinite; animation-delay: calc(var(--stride-delay, 0s) + var(--leg-phase, 0s)); }
  .home-race-tail { transform-origin: -23px -32px; animation: home-race-tail .72s ease-in-out infinite alternate; animation-delay: var(--stride-delay, 0s); }
  .home-race-track-dashes { animation: home-race-ground 1.8s linear infinite; }
  .home-race-clouds { animation: home-race-clouds 12s ease-in-out infinite alternate; }
  .home-die { animation: home-die-toss 5.6s ease-in-out infinite; animation-delay: var(--toss-delay, 0s); }
  .home-dice-spark { animation: home-dice-spark 5.6s ease-in-out infinite; }
  .home-dice-spark-two { animation-delay: -2.8s; }
  .hero.game-home .home-game-quick .home-quick-wheel { animation: home-roulette-spin 7s cubic-bezier(.16,.75,.22,1) infinite; }
  .hero.game-home .home-game-quick .home-quick-ladder { animation: home-ladder-float 3s ease-in-out infinite alternate; }
}
@media (prefers-reduced-motion: reduce) {
  .hero.game-home .home-game-art * { animation: none !important; }
}
@keyframes home-race-gallop {
  0%, 100% { transform: translateY(0) rotate(1.5deg); }
  45% { transform: translateY(-2.5px) rotate(-2deg); }
  75% { transform: translateY(1px) rotate(2deg); }
}
@keyframes home-race-stride {
  0%, 100% { transform: rotate(-32deg); }
  50% { transform: rotate(28deg); }
}
@keyframes home-race-knee {
  0%, 100% { transform: rotate(8deg); }
  35% { transform: rotate(4deg); }
  62% { transform: rotate(36deg); }
  82% { transform: rotate(52deg); }
}
@keyframes home-race-tail {
  from { transform: rotate(-9deg); }
  to { transform: rotate(9deg); }
}
@keyframes home-race-ground { to { transform: translateX(-124px); } }
@keyframes home-race-clouds { to { transform: translateX(-16px); } }
@keyframes home-die-toss {
  0%, 58%, 100% { transform: translateY(0) rotate(var(--die-angle)); }
  68% { transform: translateY(-14px) rotate(calc(var(--die-angle) - 22deg)); }
  77% { transform: translateY(2px) rotate(calc(var(--die-angle) + 12deg)); }
  84% { transform: translateY(-3px) rotate(calc(var(--die-angle) - 5deg)); }
  91% { transform: translateY(0) rotate(var(--die-angle)); }
}
@keyframes home-dice-spark {
  0%, 58%, 100% { transform: scale(.85) rotate(-5deg); opacity: .55; }
  75% { transform: scale(1.12) rotate(12deg); opacity: 1; }
}
@keyframes home-roulette-spin {
  0% { transform: rotate(-14deg); }
  60%, 100% { transform: rotate(346deg); }
}
@keyframes home-ladder-float {
  from { transform: translateY(0); }
  to { transform: translateY(-4px); }
}


/* Today's game reuses the same illustration and entry point as its directory tile. */
.home-featured :is(.home-featured-play,.home-help-button)[hidden],
.home-featured .home-featured-illustration[hidden] { display: none !important; }
.home-featured .home-featured-play[href] { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.home-featured:not([data-featured-game="race"]) .home-race-scene { display: none; }
.home-featured-illustration { position: absolute; inset: 0; display: grid; place-items: center; padding: 14px; box-sizing: border-box; overflow: hidden; }
.home-featured-illustration > svg { display: block; width: min(84%, 190px); height: min(82%, 160px); overflow: visible; }
.home-featured-illustration > .home-dice-art { position: relative; width: 124px; height: 104px; max-height: none; margin: auto; transform: scale(1.12); transform-origin: center; }
.home-tile-payment-card .home-tile-art { background: #e6efe9; }
.home-featured[data-featured-game="dice"] .home-race-art { background: #f0e4d4; }
.home-featured[data-featured-game="hwatu"] .home-race-art { background: #eee3d9; }
.home-featured[data-featured-game="roulette"] .home-race-art { background: #e9e3f0; }
.home-featured[data-featured-game="ladder"] .home-race-art { background: #dfeae3; }
.home-featured[data-featured-game="marble"] .home-race-art { background: #e4f0e6; }
.home-featured[data-featured-game="diecast"] .home-race-art { background: #dbebdc; }
.home-featured[data-featured-game="sticky"] .home-race-art { background: #d4e7ee; }
.home-featured[data-featured-game="balloon"] .home-race-art { background: #f3e5d9; }
.home-featured[data-featured-game="cards"] .home-race-art { background: #dde8ef; }
.home-featured[data-featured-game="payment-card"] .home-race-art { background: #e6efe9; }
.home-featured[data-featured-game="pirate"] .home-race-art { background: #d9e8e4; }
.home-featured[data-featured-game="bomb"] .home-race-art { background: #dae6e5; }
.home-featured[data-featured-game="reaction"] .home-race-art { background: #e2ebd2; }
.home-featured[data-featured-game="timer"] .home-race-art { background: #ece5d3; }

/* Lightweight illustrations (no GIF downloads or animation frames on the JS thread).
   HomeMotion observes each preview and pauses it offscreen or on request. */
@media (prefers-reduced-motion: no-preference) {
  .home-tile-race .home-tile-art > svg { animation: home-preview-run .85s ease-in-out infinite; }
  .home-tile-hwatu .home-tile-art > svg > g:first-child,
  .home-tile-cards .home-tile-art > svg > g:first-child { transform-box: fill-box; transform-origin: 50% 88%; animation: home-preview-card 3.4s ease-in-out infinite alternate; }
  .home-tile-hwatu .home-tile-art > svg > g:last-child,
  .home-tile-cards .home-tile-art > svg > g:last-child { transform-box: fill-box; transform-origin: 50% 88%; animation: home-preview-card 3.4s ease-in-out -1.6s infinite alternate-reverse; }
  .home-tile-roulette .home-tile-art > svg { animation: home-preview-wheel 4.2s ease-in-out infinite; }
  .home-tile-marble .home-tile-art > svg > g:nth-child(3) { animation: home-preview-marble 2.7s ease-in-out infinite alternate; }
  .home-tile-ladder .home-tile-art > svg > path:nth-of-type(2) { stroke-dasharray: 12 5; animation: home-preview-ladder 1.4s linear infinite; }
  .home-tile-balloon .home-tile-art > svg { animation: home-preview-float 3.1s ease-in-out infinite alternate; }
  .home-tile-bomb .home-tile-art > svg { animation: home-preview-bomb 3.1s ease-in-out infinite; }
  .home-tile-reaction .home-tile-art > svg > circle:last-of-type { animation: home-preview-green 2.6s ease-in-out infinite; }
  .home-tile-timer .home-tile-art > svg > path:nth-of-type(3) { transform-origin: 61px 57px; animation: home-preview-clock 5s linear infinite; }
  .home-featured:not([data-featured-game="race"]) .home-featured-illustration > svg { animation: home-preview-float 3s ease-in-out infinite alternate; }
  .home-featured .home-dice-art .home-die { animation: home-die-toss 5.6s ease-in-out infinite; animation-delay: var(--toss-delay, 0s); }
}
/* Board and poker scenes: animate the game pieces, not the entire card.
   Existing HomeMotion observer pauses these SVG animations outside the viewport. */
.home-tile-chess .home-chess-king,
.home-tile-chess .home-chess-rook,
.home-tile-janggi .home-janggi-piece,
.home-tile-omok .home-omok-last-stone,
.home-tile-yut .home-yut-motion,
.home-tile-holdem .home-poker-motion {
  transform-box: fill-box;
  transform-origin: center;
}
.home-tile-janggi .home-janggi-shadow,
.home-tile-omok .home-omok-landing { transform-box:fill-box; transform-origin:center; }
.home-tile-yut .home-yut-motion--left { --yut-tilt:-5deg; --yut-rise:-5px; --yut-delay:0s; }
.home-tile-yut .home-yut-motion--mid-left { --yut-tilt:3deg; --yut-rise:-7px; --yut-delay:-.12s; }
.home-tile-yut .home-yut-motion--mid-right { --yut-tilt:-4deg; --yut-rise:-6px; --yut-delay:-.07s; }
.home-tile-yut .home-yut-motion--right { --yut-tilt:5deg; --yut-rise:-4px; --yut-delay:-.16s; }
@media (prefers-reduced-motion: no-preference) {
  .home-tile-chess .home-chess-king { animation: home-chess-step 5.2s ease-in-out infinite; }
  .home-tile-chess .home-chess-rook { animation: home-chess-rook-step 5.2s ease-in-out infinite; }
  .home-tile-janggi .home-janggi-piece { animation: home-janggi-place 4.8s cubic-bezier(.2,.75,.3,1) infinite; }
  .home-tile-janggi .home-janggi-shadow { animation: home-janggi-shadow 4.8s ease-in-out infinite; }
  .home-tile-omok .home-omok-last-stone { animation: home-omok-place 4.5s ease-in-out infinite; }
  .home-tile-omok .home-omok-landing { animation: home-omok-ring 4.5s ease-out infinite; }
  .home-tile-yut .home-yut-motion { animation: home-yut-toss 4.6s ease-in-out var(--yut-delay) infinite; }
  .home-tile-holdem .home-poker-motion--left { animation: home-poker-fan-left 4.5s ease-in-out infinite; }
  .home-tile-holdem .home-poker-motion--middle { animation: home-poker-center 4.5s ease-in-out infinite; }
  .home-tile-holdem .home-poker-motion--right { animation: home-poker-fan-right 4.5s ease-in-out infinite; }
}
@keyframes home-chess-step {
  0%,16%,49%,100% { transform:translateY(0); }
  25% { transform:translateY(-4px); }
  36%,39% { transform:translateY(-2px); }
  43% { transform:translateY(1px); }
}
@keyframes home-chess-rook-step {
  0%,47%,86%,100% { transform:translate(0,0); }
  56% { transform:translate(1px,-3px); }
  72% { transform:translate(-3px,-1px); }
  78% { transform:translate(-3px,0); }
}
@keyframes home-janggi-place {
  0%,12%,74%,100% { transform:translateY(0); }
  25% { transform:translateY(-6px) rotate(-3deg); }
  42% { transform:translateY(-7px) rotate(-3deg); }
  52% { transform:translateY(1px); }
  57% { transform:translateY(-1px); }
}
@keyframes home-janggi-shadow {
  0%,12%,74%,100% { transform:scaleX(1); opacity:.13; }
  25%,42% { transform:scaleX(.85); opacity:.07; }
}
@keyframes home-omok-place {
  0%,12% { opacity:0; transform:translateY(-13px) scale(.85); }
  22% { opacity:1; transform:translateY(1px) scale(1.04); }
  28%,78% { opacity:1; transform:translateY(0) scale(1); }
  89%,100% { opacity:0; transform:translateY(0) scale(.92); }
}
@keyframes home-omok-ring {
  0%,16%,85%,100% { opacity:0; transform:scale(.65); }
  23% { opacity:.38; transform:scale(1.12); }
  40% { opacity:0; transform:scale(1.6); }
}
@keyframes home-yut-toss {
  0%,12%,42%,100% { transform:translateY(0) rotate(0); }
  21% { transform:translateY(var(--yut-rise)) rotate(var(--yut-tilt)); }
  28% { transform:translateY(1px) rotate(-1deg); }
  34% { transform:translateY(-2px) rotate(1deg); }
}
@keyframes home-poker-fan-left {
  0%,15%,74%,100% { transform:translate(0,0) rotate(0); }
  36%,52% { transform:translate(-5px,-3px) rotate(-5deg); }
  63% { transform:translate(-2px,-1px) rotate(-2deg); }
}
@keyframes home-poker-center {
  0%,15%,74%,100% { transform:translateY(0); }
  36%,52% { transform:translateY(-5px); }
  63% { transform:translateY(-2px); }
}
@keyframes home-poker-fan-right {
  0%,15%,74%,100% { transform:translate(0,0) rotate(0); }
  36%,52% { transform:translate(5px,-3px) rotate(5deg); }
  63% { transform:translate(2px,-1px) rotate(2deg); }
}

@keyframes home-preview-run { 0%,100% { transform:translate(0,0) rotate(-1deg); } 50% { transform:translate(3px,-5px) rotate(1deg); } }
@keyframes home-preview-card { from { transform:rotate(-5deg) translateY(1px); } to { transform:rotate(6deg) translateY(-3px); } }
@keyframes home-preview-wheel { 0%,100% { transform:rotate(-8deg); } 48% { transform:rotate(12deg); } 70% { transform:rotate(3deg); } }
@keyframes home-preview-marble { from { transform:translate(-2px,-4px) rotate(-3deg); transform-origin:62px 45px; } to { transform:translate(3px,6px) rotate(4deg); transform-origin:62px 45px; } }
@keyframes home-preview-ladder { to { stroke-dashoffset:-34; } }
@keyframes home-preview-float { from { transform:translateY(4px) rotate(-2deg); } to { transform:translateY(-5px) rotate(2deg); } }
@keyframes home-preview-bomb { 0%,80%,100% { transform:scale(1); } 85% { transform:scale(1.05); } 90% { transform:scale(.98); } }
@keyframes home-preview-green { 0%,25%,100% { fill:#75938a; } 35%,75% { fill:#bde69b; } }
@keyframes home-preview-clock { to { transform:rotate(360deg); } }
@media (max-width: 600px) {
  .home-featured-illustration { padding: 8px; }
  .home-featured-illustration > svg { width: min(88%, 112px); height: min(86%, 94px); overflow: visible; }
  .home-featured-illustration > .home-dice-art { width: 124px; height: 104px; margin: auto; transform: scale(.78); transform-origin: center; }
}
/* Header controls share one row; the menu stylesheet must not restore its dark skin. */
.game-portal .site-header #hamburgerBtn.hamburger-menu { background:#edf2ff; border-color:#d4dffb; min-width:108px; }
.game-portal .site-header #hamburgerBtn.hamburger-menu:hover,
.game-portal .site-header #hamburgerBtn.hamburger-menu[aria-expanded="true"] { background:#dfe8ff; border-color:#a8beee; }
@media(max-width:600px) {
  .game-portal .site-header #hamburgerBtn.hamburger-menu { min-width:38px; }
  .home-welcome { padding:18px 16px 16px; margin-bottom:22px; }
  .game-home h1 { font-size:clamp(22px,6.2vw,26px); }
  .home-featured { margin-top:14px; grid-template-columns:126px minmax(0,1fr); }
  .home-featured .home-race-art { min-height:114px; }
  .home-featured-copy { display:flex; flex-direction:column; align-items:flex-start; justify-content:center; gap:5px; padding:12px 14px; }
  .home-featured-label { padding:3px 7px; background:#edf1ff; font-size:10.5px; }
  .home-featured h2 { font-size:17px; line-height:1.3; }
  .home-featured-actions { margin:2px 0 0; }
  .home-featured-play { min-height:36px; padding:7px 13px; font-size:12px; white-space:nowrap; }
  .home-featured .home-help-button { display:none; }
  .home-featured-illustration > svg { width:min(88%, 112px); height:min(86%, 94px); overflow:visible; }
  .home-featured-illustration > .home-dice-art { width:124px; height:104px; min-width:0; margin:auto; transform:scale(.78); transform-origin:center; }
  .home-filter-row { display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:8px; padding-bottom:12px; }
  .home-filters { flex-wrap:wrap; overflow-x:visible; padding-bottom:0; gap:6px; width:100%; }
  .home-filters button { flex:0 0 auto; white-space:nowrap; }
  #home-catalog-status { display:block; width:100%; margin-top:2px; }
}
@media(max-width:359px) {
  .home-featured { grid-template-columns:108px minmax(0,1fr); }
  .home-featured .home-race-art { min-height:106px; }
  .home-featured-illustration > svg { width:min(88%, 96px); height:min(86%, 82px); }
  .home-featured-illustration > .home-dice-art { transform:scale(.68); }
}

/* Sticky character preview in the home game catalog. */
.home-tile-sticky .home-tile-art { background: #d4e7ee; }
.home-tile-sticky .home-sticky-glob { animation: home-sticky-splat 3s cubic-bezier(.3,.75,.5,1) infinite; transform-origin: 53px 40px; }
.home-tile-sticky .home-sticky-glob-two { animation: home-sticky-bob 3s ease-in-out infinite; transform-origin: 92px 72px; }
@keyframes home-sticky-splat { 0%,12% {transform:translate(8px,75px) scale(.6);opacity:.2} 28%{transform:translate(0,-6px) scale(1.2,.8);opacity:1} 42%,89%{transform:translate(0,0) scale(1,1)} 100%{opacity:0} }
@keyframes home-sticky-bob {0%,100%{transform:scale(1)}50%{transform:scale(1.13,.88)}}
@media(prefers-reduced-motion:reduce){.home-tile-sticky .home-sticky-glob,.home-tile-sticky .home-sticky-glob-two{animation:none}}

/* Homepage share action complements its existing BGM and games controls. */
.game-portal .site-header .home-share-button {
  min-height:42px;display:inline-flex;align-items:center;justify-content:center;gap:7px;
  padding:0 13px;border:1px solid #d5dff0;border-radius:12px;
  background:#f4f7ff;color:#3158bd;white-space:nowrap;
  font:750 12px/1.2 system-ui,'Apple SD Gothic Neo',sans-serif;cursor:pointer;
}
.game-portal .site-header .home-share-button:hover {background:#e7efff;border-color:#adc1ed;}
.game-portal .site-header .home-share-button:focus-visible {outline:3px solid #315de1;outline-offset:3px;}
.game-portal .site-header .home-share-button>span:first-child {font-size:19px;line-height:1;}
@media(max-width:550px) {
  .game-portal .site-header .home-share-button {width:38px;min-width:38px;padding:0;}
  .game-portal .site-header .home-share-label {display:none;}
}

/* Main-page sound mixer: a single, compact header control for both channels. */
.game-portal .site-header .home-audio { position:relative; flex:0 0 auto; z-index:125; }
.game-portal .site-header .home-audio-trigger {
  display:inline-flex;align-items:center;justify-content:center;gap:8px;
  min-height:42px;padding:0 13px;border:1px solid #d5dff0;border-radius:12px;
  color:#3158bd;background:#f4f7ff;white-space:nowrap;
  font:750 12px/1.2 system-ui,'Apple SD Gothic Neo',sans-serif;cursor:pointer;
}
.game-portal .site-header .home-audio-trigger:hover,
.game-portal .site-header .home-audio-trigger[aria-expanded="true"] { background:#e7efff;border-color:#adc1ed; }
.game-portal .site-header .home-audio-trigger svg { display:block;width:19px;height:19px;flex:0 0 19px; }
.game-portal .site-header .home-audio-panel {
  position:absolute;top:calc(100% + 12px);right:0;width:304px;max-width:calc(100vw - 24px);
  padding:18px;border:1px solid #d7e0f1;border-radius:16px;
  background:#fff;color:#263750;box-shadow:0 14px 40px #172f5f30;
  font-family:system-ui,'Apple SD Gothic Neo',sans-serif;text-align:left;
}
.game-portal .site-header .home-audio-panel[hidden] { display:none; }
.game-portal .site-header .home-audio-panel h2 { margin:0 0 12px;font-size:16px;font-weight:800;line-height:1.3;color:#263750; }
.game-portal .site-header .home-audio-channel { padding:12px 0;border-top:1px solid #e6ebf5; }
.game-portal .site-header .home-audio-channel-head,
.game-portal .site-header .home-audio-volume { display:flex;align-items:center;justify-content:space-between;gap:12px; }
.game-portal .site-header .home-audio-channel-head label { color:#344666;font-size:13px;font-weight:750; }
.game-portal .site-header .home-audio-switch {
  min-width:58px;min-height:32px;padding:5px 10px;border:1px solid #a8bee9;
  border-radius:20px;color:#244da5;background:#ecf2ff;
  font:750 12px/1.2 system-ui,'Apple SD Gothic Neo',sans-serif;cursor:pointer;
}
.game-portal .site-header .home-audio-switch[aria-pressed="false"] {
  background:#f1f3f6;border-color:#d7dce6;color:#6c7688;
}
.game-portal .site-header .home-audio-volume { margin-top:9px; }
.game-portal .site-header .home-audio-volume input[type=range] {
  flex:1;min-width:0;min-height:30px;margin:0;padding:0;border:0;
  background:transparent;accent-color:#315de1;cursor:pointer;
}
.game-portal .site-header .home-audio-volume output {
  width:42px;flex:0 0 42px;text-align:right;color:#4e607e;font-size:12px;font-variant-numeric:tabular-nums;
}
@media(max-width:550px) {
  .game-portal .site-header .home-audio-trigger { width:38px;min-width:38px;padding:0; }
  .game-portal .site-header .home-audio-trigger span { display:none; }
}

/* Moving downhill diecast preview: overtaking happens within a clipped card. */
.home-tile-diecast .home-tile-art{background:#dbebdc}
.home-tile-diecast .home-diecast-red{animation:home-diecast-pass 2.8s ease-in-out infinite}
.home-tile-diecast .home-diecast-blue{animation:home-diecast-chase 2.8s ease-in-out infinite}
@keyframes home-diecast-pass{0%,100%{transform:translate(28px,22px) rotate(-12deg)}45%{transform:translate(37px,38px) rotate(-4deg)}65%{transform:translate(16px,47px) rotate(-14deg)}}
@keyframes home-diecast-chase{0%,100%{transform:translate(68px,38px) rotate(7deg)}45%{transform:translate(66px,14px) rotate(-8deg)}70%{transform:translate(69px,50px) rotate(4deg)}}
@media(prefers-reduced-motion:reduce){.home-tile-diecast .home-diecast-red,.home-tile-diecast .home-diecast-blue{animation:none}}


/* Same touch and control geometry as the standalone game header. */
.game-portal .site-header :is(#hamburgerBtn,.home-audio-trigger,.home-share-button) {
  min-height:44px;min-width:44px;
}
.game-portal .site-header .home-audio-switch {min-height:44px;min-width:44px;}
.game-portal .site-header .home-audio-panel :is(button,input):focus-visible {
  outline:3px solid #315de1;outline-offset:3px;
}

/* New board and poker previews: animate only the pieces, not the layout. */
.home-tile-reversi .home-tile-art { background:#e3e8d9; }
.home-tile-omaha .home-tile-art { background:#dce7dc; }
.home-reversi-white,.home-reversi-black,.home-reversi-place,.home-reversi-hint,.home-omaha-card { transform-box:fill-box;transform-origin:center; }
.home-reversi-black,.home-reversi-place { opacity:0; }
.home-omaha-card--1 { --omaha-spread:-5px;--omaha-tilt:-5deg;--omaha-rise:-2px; }
.home-omaha-card--2 { --omaha-spread:-2px;--omaha-tilt:-2deg;--omaha-rise:-6px; }
.home-omaha-card--3 { --omaha-spread:2px;--omaha-tilt:2deg;--omaha-rise:-6px; }
.home-omaha-card--4 { --omaha-spread:5px;--omaha-tilt:5deg;--omaha-rise:-2px; }
@media (prefers-reduced-motion:no-preference) {
  .home-reversi-place { animation:home-reversi-place 5s ease-in-out infinite; }
  .home-reversi-hint { animation:home-reversi-hint 5s ease-in-out infinite; }
  .home-reversi-white { animation:home-reversi-white 5s ease-in-out infinite; }
  .home-reversi-black { animation:home-reversi-black 5s ease-in-out infinite; }
  .home-omaha-card { animation:home-omaha-fan 4.8s ease-in-out infinite; }
}
@keyframes home-reversi-place {
  0%,12%,92%,100% { opacity:0;transform:translateY(-9px) scale(.9); }
  24% { opacity:1;transform:translateY(1px) scale(1.04); }
  29%,84% { opacity:1;transform:translateY(0) scale(1); }
}
@keyframes home-reversi-hint {
  0%,10%,100% { opacity:1; } 24%,86% { opacity:0; }
}
@keyframes home-reversi-white {
  0%,30%,100% { opacity:1;transform:scaleY(1); }
  39% { opacity:1;transform:scaleY(.05); }
  40%,85% { opacity:0;transform:scaleY(.05); }
  91% { opacity:1;transform:scaleY(.05); }
}
@keyframes home-reversi-black {
  0%,39%,92%,100% { opacity:0;transform:scaleY(.05); }
  40% { opacity:1;transform:scaleY(.05); }
  49%,84% { opacity:1;transform:scaleY(1); }
  90% { opacity:0;transform:scaleY(.05); }
}
@keyframes home-omaha-fan {
  0%,14%,78%,100% { transform:translate(0,0) rotate(0); }
  35%,58% { transform:translate(var(--omaha-spread),var(--omaha-rise)) rotate(var(--omaha-tilt)); }
}

/* New previews retain the shared visibility/pause gate; only the game action moves. */
.home-tile-connect-four .home-tile-art { background:#d5e7e9; }
.home-tile-draw-poker .home-tile-art { background:#e1e9dd; }
.home-connect-win { opacity:0; }
@media(prefers-reduced-motion:no-preference) {
  .home-connect-drop { animation:home-connect-drop 4.8s ease-in-out infinite; }
  .home-connect-win { animation:home-connect-win 4.8s ease-in-out infinite; }
  .home-draw-exchange { animation:home-draw-exchange 5.2s ease-in-out infinite; }
}
@media(prefers-reduced-motion:reduce) { .home-connect-win { opacity:1; } }
@keyframes home-connect-drop {
  0%,15% { transform:translateY(-76px); opacity:0; }
  22% { opacity:1; }
  38% { transform:translateY(0); }
  43% { transform:translateY(-5px); }
  48%,88% { transform:translateY(0); opacity:1; }
  100% { transform:translateY(0); opacity:0; }
}
@keyframes home-connect-win { 0%,48%,100% { opacity:0; } 55%,88% { opacity:.85; } }
@keyframes home-draw-exchange {
  0%,18%,78%,100% { transform:translateY(0); opacity:1; }
  34%,47% { transform:translateY(-12px); opacity:.25; }
  59% { transform:translateY(-12px); opacity:1; }
}

/* ---- css/modules/game-hub.css ---- */
/* Game library overlay: one searchable directory, one persistent utility shelf. */
#hamburgerBtn.hamburger-menu { display:inline-flex; flex-direction:row; gap:9px; align-items:center; justify-content:center; width:auto; min-width:126px; height:43px; padding:0 15px; border-radius:11px; border-color:#d4dffb; background:#edf2ff; color:#244db0; font-size:12px; font-weight:750; white-space:nowrap; }
#hamburgerBtn.hamburger-menu:hover,#hamburgerBtn.hamburger-menu[aria-expanded="true"] { border-color:#a8beee; background:#e4ecff; }
.menu-trigger-bars { width:17px; flex:0 0 17px; display:grid; grid-template-rows:repeat(3,2px); gap:4px; }
#hamburgerBtn .hamburger-line { width:100%; height:2px; border-radius:3px; background:#315de1; }
.menu-trigger-label { color:#244db0; }
.menu-trigger-suffix { color:#53647b; }
#main-menu .game-hub-shell { width:100%; max-width:970px; max-height:min(860px,calc(100dvh - 30px)); padding:0; overflow-y:auto; border:1px solid #d8e0f0; border-radius:19px; background:#ffffff; box-shadow:0 28px 95px #1727443b,0 0 0 1px #315de108; }
#main-menu .game-hub-heading { display:flex; align-items:center; justify-content:space-between; gap:18px; position:sticky; top:0; z-index:4; margin:0; padding:25px 30px 17px; background:#ffffff; border-bottom:0; }
.game-hub-heading-copy { min-width:0; }
.game-hub-brand { display:block; color:#53647b; font-size:11px; font-weight:650; margin:0 0 5px; }
#main-menu #game-hub-title { margin:0 0 5px; color:#25344e; font-size:clamp(21px,3vw,27px); line-height:1.3; letter-spacing:-.04em; font-weight:850; text-shadow:none; }
#game-hub-intro { font-size:12px; color:#65738b; margin:0; line-height:1.6; }
#main-menu .game-hub-heading .close-modal-button { margin:0; background:#edf2ff; color:#425d99; border:1px solid #ccd8ef; border-radius:11px; }
#main-menu .game-hub-heading .close-modal-button:hover { color:#244db0; background:#dfe8ff; }
.game-hub-search-wrap { padding:0 30px 23px; background:#ffffff; }
.game-hub-search { display:flex; gap:10px; align-items:center; min-height:47px; padding:0 14px; background:#f7f9ff; border:1px solid #cbd5e7; border-radius:11px; color:#65738b; transition:border-color .15s,box-shadow .15s; }
.game-hub-search:focus-within { border-color:#315de1; box-shadow:0 0 0 3px #315de120; }
.game-hub-search svg { flex:0 0 19px; width:19px; height:19px; }
.game-hub-search input { min-width:0; flex:1; padding:12px 0; background:transparent; border:0; outline:0; box-shadow:none; color:#25344e; font:inherit; font-size:13px; }
.game-hub-search input::placeholder { color:#65738b; opacity:1; }
.game-hub-search input::-webkit-search-cancel-button { cursor:pointer; }
.game-hub-search kbd { display:grid; place-items:center; width:23px; height:23px; border-radius:5px; border:1px solid #ccd8ef; font:12px system-ui,sans-serif; color:#53647b; }
.game-hub-content { display:grid; grid-template-columns:215px minmax(0,1fr); min-height:330px; border-block:1px solid #dbe3f1; }
.game-hub-categories { display:flex; flex-direction:column; gap:4px; padding:21px 13px 20px 20px; background:#f2f5fd; border-right:1px solid #dbe3f1; }
.game-hub-category { min-height:45px; width:100%; display:flex; align-items:center; justify-content:space-between; gap:10px; padding:10px 12px; background:transparent; color:#53647b; border:1px solid transparent; border-radius:9px; text-align:left; cursor:pointer; font-size:13px; font-weight:700; }
.game-hub-category:hover { color:#244db0; background:#e7edfb; }
.game-hub-category[aria-pressed="true"] { background:#315de1; border-color:#315de1; color:#ffffff; }
.game-hub-category-count { color:inherit; opacity:.7; font-variant-numeric:tabular-nums; font-size:11px; }
.game-hub-results { min-width:0; padding:20px 26px 25px; background:#ffffff; }
.game-hub-results-heading { display:flex; justify-content:space-between; align-items:center; gap:12px; margin:0 0 8px; }
.game-hub-results-heading h3 { margin:0; color:#25344e; font-size:15px; font-weight:800; letter-spacing:-.02em; }
#game-hub-count { color:#53647b; font-size:11px; white-space:nowrap; }
.game-hub-list { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:2px 12px; }
.game-hub-game { display:flex; gap:11px; align-items:center; text-align:left; min-width:0; min-height:78px; padding:12px 8px; font:inherit; background:transparent; border:0; border-bottom:1px solid #e3e8f3; border-radius:0; color:#25344e; text-decoration:none; cursor:pointer; }
.game-hub-game:hover,.game-hub-game:focus-visible { background:#edf2ff; border-radius:8px; border-bottom-color:#a8beee; color:#244db0; }
.game-hub-game-icon { display:grid; place-items:center; width:40px; height:40px; flex:0 0 40px; background:#edf2ff; color:#244db0; border:1px solid #d8e1f4; border-radius:11px; font-size:21px; }
.game-hub-game-copy { min-width:0; flex:1; display:flex; flex-direction:column; gap:4px; }
.game-hub-game-title { display:block; font-size:13px; line-height:1.35; color:#25344e; font-weight:800; overflow-wrap:anywhere; }
.game-hub-game-desc { display:-webkit-box; -webkit-box-orient:vertical; -webkit-line-clamp:2; overflow:hidden; color:#65738b; font-size:11px; line-height:1.5; }
.game-hub-game-tail { flex:0 0 15px; display:grid; align-items:center; justify-items:end; gap:7px; color:#536ba1; }
.game-hub-game-tail small { display:none; }
.game-hub-game-arrow { font-size:17px; font-weight:500; }
.game-hub-empty { padding:36px 10px; color:#65738b; text-align:center; font-size:13px; }
.game-hub-empty[hidden] { display:none !important; }
.game-hub-utilities { padding:22px 30px 25px; background:#ffffff; }
.game-hub-utilities h3 { font-size:12px; color:#53647b; font-weight:700; margin:0 0 12px; }
#main-menu .game-hub-utilities .menu-buttons { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:10px; margin:0; }
#main-menu .game-hub-utilities .menu-button { min-width:0; min-height:55px; display:flex; flex-direction:row; align-items:center; justify-content:flex-start; gap:9px; padding:10px 12px; margin:0; border:1px solid #d8e1f4; border-radius:10px; background:#f3f6fd; color:#344663; font-size:12px; box-shadow:none; transition:background .15s,border-color .15s; }
#main-menu .game-hub-utilities .menu-button:hover { background:#e4ecff; border-color:#a8beee; color:#244db0; transform:none; }
#main-menu .game-hub-utilities .menu-button-icon { font-size:20px; margin:0; }
#main-menu .game-hub-utilities .menu-button-text { min-width:0; font-weight:750; }
@media(max-width:700px) {
  #main-menu .game-hub-shell { max-height:calc(100dvh - 16px); }
  #main-menu .game-hub-heading { padding:14px 16px 10px; gap:12px; }
  .game-hub-brand { font-size:10px; margin:0 0 2px; }
  #main-menu #game-hub-title { font-size:18px; margin:0 0 2px; }
  #game-hub-intro { font-size:11.5px; line-height:1.4; }
  .game-hub-search-wrap { padding:0 16px 12px; }
  .game-hub-search { min-height:42px; padding:0 12px; gap:8px; }
  .game-hub-search input { padding:9px 0; font-size:14px; }
  .game-hub-content { grid-template-columns:1fr; }
  .game-hub-categories { flex-direction:row; overflow-x:auto; padding:8px 14px; gap:6px; border-right:0; border-bottom:1px solid #dbe3f1; scrollbar-width:thin; }
  .game-hub-category { min-height:34px; width:auto; flex:0 0 auto; white-space:nowrap; padding:6px 10px; font-size:12px; border-color:#d8e1f4; background:#f4f7ff; }
  .game-hub-results { padding:12px 14px 16px; }
  .game-hub-utilities { padding:12px 14px 14px; }
  .game-hub-utilities h3 { font-size:11px; margin:0 0 8px; }
}
@media(max-width:520px) {
  #hamburgerBtn.hamburger-menu { min-width:38px; padding:0 10px; gap:7px; }
  .menu-trigger-suffix { display:none; }
  #main-menu .game-hub-shell { border-radius:14px; }
  #main-menu .game-hub-heading .close-modal-button { min-width:38px; width:38px; height:38px; min-height:38px; }
  .game-hub-list { grid-template-columns:1fr; }
  .game-hub-game { min-height:62px; padding:9px 6px; gap:10px; }
  .game-hub-game-icon { width:36px; height:36px; flex:0 0 36px; font-size:18px; border-radius:9px; }
  #main-menu .game-hub-utilities .menu-buttons { grid-template-columns:repeat(2,minmax(0,1fr)); gap:6px; }
  #main-menu .game-hub-utilities .menu-button { min-height:42px; padding:7px 10px; font-size:11.5px; gap:7px; }
  #main-menu .game-hub-utilities .menu-button-icon { font-size:16px; }
}
@media(prefers-reduced-motion:reduce) { .game-hub-search,#main-menu .game-hub-utilities .menu-button { transition:none; } }

/* Keep game browsing separate from utility actions: the game list scrolls, not the whole menu. */
#main-menu .game-hub-shell { display:flex; flex-direction:column; overflow:hidden; height:min(800px,calc(100dvh - 30px)); }
#main-menu .game-hub-heading, .game-hub-search-wrap, .game-hub-utilities { flex:0 0 auto; }
#main-menu .game-hub-heading { position:relative; top:auto; }
.game-hub-content { flex:1 1 auto; min-height:0; overflow:hidden; }
.game-hub-results { min-height:0; overflow-y:auto; overscroll-behavior:contain; scrollbar-color:#9bacca #ffffff; }
@media(max-width:700px) {
  #main-menu .game-hub-shell { height:calc(100dvh - 20px); }
  .game-hub-content { display:flex; flex-direction:column; }
  .game-hub-categories { flex:0 0 auto; }
  .game-hub-results { flex:1 1 auto; }
}

.game-portal #main-menu :is(button,a,input):focus-visible { outline:3px solid #315de1; outline-offset:3px; }
.game-portal #main-menu .game-hub-search input:focus-visible { outline:none; }

/* ---- css/modules/quick-bet.css ---- */
/* Quick coffee-bet games: roulette and ladder. */
#quickBetModal [hidden] { display: none !important; }
#quickBetModal { padding: max(12px, env(safe-area-inset-top, 0px)) 12px max(12px, env(safe-area-inset-bottom, 0px)); }
#quickBetModal .quickbet-panel {
  display: flex;
  touch-action: pan-x pan-y pinch-zoom;
  flex-direction: column;
  width: 100%;
  max-width: 620px;
  max-height: calc(100vh - 48px);
  max-height: calc(100dvh - 48px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  padding: 0;
  margin: 12px auto;
  overflow: hidden;
  animation: none;
  transform: none;
  border-color: #52657c;
  box-shadow: 0 18px 58px #050b105e;
}
#quickBetModal .modal-header { flex: 0 0 auto; position: static; margin: 0; padding: 16px 20px; gap: 16px; }
#quickBetModal .modal-header h2 { color: #eef1e6; font-size: 21px; line-height: 1.4; text-shadow: none; }
#quickbet-close { width: 44px; height: 44px; flex: 0 0 44px; padding: 0; border-radius: 9px; background: #21373b; }
.quickbet-content { min-height: 0; padding: 20px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.quickbet-intro { margin: 0 0 18px; color: #b7c8c3; font-size: 13px; line-height: 1.8; word-break: keep-all; }
.quickbet-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; padding: 4px; border: 1px solid #4b6268; border-radius: 11px; background: #12262d; }
.quickbet-tab { min-height: 46px; padding: 9px 12px; border-radius: 8px; color: #c5d4d0; font-size: 12px; font-weight: 600; line-height: 1.45; }
.quickbet-tab.active { color: #24303d; background: #b9c8ff; }
.quickbet-tab:not(.active):hover { background: #284149; }
.quickbet-mode-description { min-height: 3.2em; margin: 12px 0 18px; color: #a8bbb8; font-size: 11px; line-height: 1.65; }
.quickbet-winner-field { margin-top: 14px; padding-top: 14px; border-top: 1px solid #31494f; }
.quickbet-wheel-slice.is-winner { filter: drop-shadow(0 0 5px #f8ffd9) drop-shadow(0 0 10px #d5ef96a0); }
.quickbet-field label { display: block; margin-bottom: 7px; color: #deeadf; font-size: 12px; font-weight: 600; }
#quickBetModal select,
#quickBetModal input {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid #4a6264;
  border-radius: 8px;
  background: #11262d;
  color: #f0f3e9;
  font: inherit;
  font-size: 16px;
  box-shadow: none;
  color-scheme: dark;
}
#quickBetModal :is(select,input):focus-visible,
.quickbet-tab:focus-visible {
  border-color: #b9c8ff;
  outline: 2px solid #b9c8ff;
  outline-offset: 2px;
}
.quickbet-names-title { margin: 22px 0 0; color: #e3ebdc; font-size: 14px; }
.quickbet-hint { margin-top: 9px; color: #a8bdb6; font-size: 11px; line-height: 1.7; overflow-wrap: anywhere; }
.quickbet-names { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 12px; }
.quickbet-name-field { display: flex; align-items: center; gap: 9px; min-width: 0; padding: 0 10px; border: 1px solid #3e575b; border-radius: 8px; background: #14272f; }
.quickbet-name-number { color: #c5c8a7; font: 11px ui-monospace, monospace; }
#quickBetModal .quickbet-name-field input { border: 0; padding-left: 0; padding-right: 0; background: none; }
#quickBetModal .quickbet-name-field input::placeholder { color: #90a8a7; font-size: 13px; }
.quickbet-name-field:focus-within { border-color: #b9c8ff; }

.quickbet-result-heading { display: flex; align-items: center; justify-content: space-between; gap: 15px; }
#quickbet-round { margin-bottom: 4px; color: #aeb9d6; font-size: 11px; }
#quickbet-result-title { color: #f0f3e9; font-size: 21px; line-height: 1.45; }
#quickbet-badge { flex-shrink: 0; padding: 5px 8px; border-radius: 5px; color: #d9e1ff; background: #34415b; font-size: 10px; }
#quickbet-status { min-height: 1.7em; margin: 12px 0; color: #c9d7c8; font-size: 11px; line-height: 1.7; }
.quickbet-visual {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
  min-height: 310px;
  padding: 14px 6px;
  border: 1px solid #3e575f;
  border-radius: 18px;
  background:
    radial-gradient(circle at 50% 40%, #395665 0, #243c47 34%, #12252c 72%),
    #12252c;
  overflow: hidden;
  overflow: clip;
  contain: paint style;
  transform: translateZ(0);
}
.quickbet-visual::before {
  content: '';
  position: absolute;
  z-index: 0;
  inset: -42%;
  border-radius: 50%;
  background: conic-gradient(from 0deg, transparent 0 15%, #b9c8ff3d 23%, transparent 31% 53%, #d5ef9638 61%, transparent 72% 100%);
  opacity: .16;
  transform: rotate(0deg) scale(.9);
  will-change: transform, opacity;
  animation: quickbet-ambient-spin 14s linear infinite;
}
.quickbet-visual::after {
  content: '';
  position: absolute;
  z-index: 3;
  top: -30%;
  bottom: -30%;
  left: -45%;
  width: 28%;
  background: linear-gradient(90deg, transparent, #ffffff22, #ffffff3d, transparent);
  opacity: 0;
  transform: translate3d(-180%,0,0) rotate(17deg);
  pointer-events: none;
}
.quickbet-visual.is-spinning::before,
.quickbet-visual.is-tracing::before,
.quickbet-visual.is-inflating::before,
.quickbet-visual.is-shuffling::before { opacity: .38; animation-duration: 2.7s; }
.quickbet-visual.is-spinning::after,
.quickbet-visual.is-tracing::after,
.quickbet-visual.is-inflating::after,
.quickbet-visual.is-shuffling::after { opacity: 1; animation: quickbet-stage-sheen 1.35s ease-in-out infinite; }

.quickbet-wheel-wrap { position: relative; z-index: 1; display: grid; place-items: center; width: min(100%, 340px); aspect-ratio: 1; padding: 9px; transform: translateZ(0); }
.quickbet-wheel { z-index: 2; width: 100%; height: 100%; transform-origin: 50% 50%; backface-visibility: hidden; filter: drop-shadow(0 14px 20px #02070852); }
.quickbet-wheel-aura,
.quickbet-wheel-orbit,
.quickbet-wheel-sheen { position: absolute; inset: 3%; border-radius: 50%; pointer-events: none; }
.quickbet-wheel-aura { z-index: 0; background: conic-gradient(from 20deg, #d5ef9675, transparent 20% 37%, #b9c8ff75 48%, transparent 62% 80%, #f4bd9566); opacity: .18; filter: blur(12px); transform: scale(.98); }
.quickbet-wheel-orbit { z-index: 1; inset: 1%; border: 2px dashed #dce7df33; opacity: .48; }
.quickbet-wheel-sheen { z-index: 3; inset: 10%; overflow: hidden; opacity: 0; background: linear-gradient(110deg, transparent 31%, #ffffff00 39%, #ffffff5c 49%, #ffffff00 59%, transparent 67%); transform: translate3d(-70%,0,0) rotate(-8deg); mix-blend-mode: screen; }
.quickbet-wheel-pointer {
  position: absolute;
  z-index: 5;
  top: -2px;
  left: 50%;
  transform: translateX(-50%);
  transform-origin: 50% 0;
  color: #fff5dc;
  font-size: 29px;
  line-height: 1;
  filter: drop-shadow(0 3px 3px #0008) drop-shadow(0 0 8px #fff0cd66);
}
.quickbet-wheel-wrap.is-spinning { animation: quickbet-wheel-breathe 1.15s ease-in-out infinite alternate; }
.quickbet-wheel-wrap.is-spinning .quickbet-wheel,
.quickbet-wheel-wrap.is-spinning .quickbet-wheel-pointer { will-change: transform; }
.quickbet-wheel-wrap.is-spinning .quickbet-wheel-aura { opacity: .72; animation: quickbet-wheel-aura-spin 1.75s linear infinite; }
.quickbet-wheel-wrap.is-spinning .quickbet-wheel-orbit { opacity: .82; animation: quickbet-wheel-orbit-spin 2.6s linear infinite reverse; }
.quickbet-wheel-wrap.is-spinning .quickbet-wheel-sheen { opacity: .78; animation: quickbet-wheel-sheen 1.1s ease-in-out infinite; }
.quickbet-wheel-wrap.is-spinning .quickbet-wheel-pointer { animation: quickbet-pointer-tick .24s ease-in-out infinite alternate; }
.quickbet-wheel-label { fill: #213239; font: 700 12px/1 system-ui, sans-serif; pointer-events: none; }
.quickbet-wheel-center { fill: #f2f4ea; font-size: 27px; pointer-events: none; }
.quickbet-wheel-grid { position: relative; z-index: 1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: center; justify-items: center; gap: 14px 10px; width: 100%; padding: 2px; }
.quickbet-wheel-grid.is-single { grid-template-columns: minmax(0, 340px); justify-content: center; }
.quickbet-wheel-grid:not(.is-single) .quickbet-wheel-wrap { width: 100%; max-width: 174px; padding: 5px; }
.quickbet-wheel-grid.is-many .quickbet-wheel-wrap { max-width: 150px; }
.quickbet-wheel-grid:not(.is-single) .quickbet-wheel-label { font-size: 9px; }
.quickbet-wheel-grid:not(.is-single) .quickbet-wheel-center { font-size: 24px; font-weight: 800; }
.quickbet-wheel-grid:not(.is-single) .quickbet-wheel-pointer { top: 0; font-size: 21px; }

.quickbet-ladder-wrap { position: relative; z-index: 1; min-width: 0; width: 100%; max-width: 720px; }
.quickbet-ladder-viewport { position: relative; min-width: 0; width: 100%; overflow: hidden; overflow: clip; }
.quickbet-ladder-viewport:focus-visible { outline-offset: -2px; border-radius: 6px; }
.quickbet-ladder-scroll-hint { display: none; }
.quickbet-ladder-svg { display: block; width: 100%; height: auto; min-height: 250px; overflow: hidden; overflow: clip; }
.quickbet-ladder-line { stroke: #69858c; stroke-width: 5; stroke-linecap: round; opacity: .86; }
.quickbet-ladder-trace-glow { stroke: var(--trace-color, #d5ef96); stroke-width: 25; stroke-linecap: round; stroke-linejoin: round; opacity: .14; filter: drop-shadow(0 0 11px #d5ef96a8); }
.quickbet-ladder-trace { stroke: var(--trace-color, #e5ff9d); stroke-width: 10; stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 0 5px #d5ef96) drop-shadow(0 0 13px #d5ef968f); }
.quickbet-ladder-runner-halo { fill: var(--trace-color, #d5ef96); fill-opacity: .22; stroke: var(--trace-color, #e8ffa8); stroke-width: 2; transform-box: fill-box; transform-origin: center; animation: quickbet-runner-halo .72s ease-out infinite; }
.quickbet-ladder-runner { fill: #f8ffd9; stroke: var(--trace-color, #d5ef96); stroke-width: 3; filter: drop-shadow(0 0 8px #e8ffa8) drop-shadow(0 0 16px #d5ef96); }
.quickbet-ladder-number { fill: #e1ece5; font: 700 17px/1 ui-monospace, monospace; }
.quickbet-ladder-number.is-winner { font-weight: 900; filter: drop-shadow(0 0 5px currentColor); }
.quickbet-ladder-coffee { fill: #fff0cd; font-size: 28px; filter: drop-shadow(0 0 5px #f4bd9590); }
.quickbet-ladder-pass { fill: #8da7a2; font: 700 18px/1 system-ui, sans-serif; }
.quickbet-ladder-svg.is-dense .quickbet-ladder-line { stroke-width: 3.7; opacity: .76; }
.quickbet-ladder-svg.is-dense .quickbet-ladder-trace-glow { stroke-width: 19; }
.quickbet-ladder-svg.is-dense .quickbet-ladder-trace { stroke-width: 7.5; }
.quickbet-ladder-svg.is-dense .quickbet-ladder-number { font-size: 18px; }
.quickbet-ladder-svg.is-dense .quickbet-ladder-pass { font-size: 15px; }
.quickbet-ladder-svg.is-dense .quickbet-ladder-coffee { font-size: 25px; }
.quickbet-ladder-caption { margin-top: -4px; color: #a9bbb6; text-align: center; font-size: 10px; line-height: 1.6; }


/* Balloon pop */
.quickbet-balloon-stage, .quickbet-card-stage { position: relative; z-index: 1; width: 100%; }
.quickbet-balloon-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: end; gap: 14px 9px; width: 100%; max-width: 540px; margin: 0 auto; padding: 10px 4px 0; }
.quickbet-balloon-item { position: relative; display: grid; place-items: center; min-width: 0; min-height: 116px; }
.quickbet-balloon-body { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; width: 82px; max-width: 100%; height: 94px; padding: 11px 7px 17px; border-radius: 50% 50% 46% 46%; color: #183039; text-align: center; background: var(--balloon-color); box-shadow: inset -10px -12px 18px #00000012, inset 9px 7px 14px #ffffff3f, 0 11px 17px #02070848; transform-origin: 50% 88%; }
.quickbet-balloon-body::before { content: ''; position: absolute; right: 18px; top: 14px; width: 15px; height: 23px; border-radius: 50%; background: #ffffff54; transform: rotate(24deg); }
.quickbet-balloon-body::after { content: ''; position: absolute; left: 50%; bottom: -13px; width: 2px; height: 22px; background: #b8c9c4a8; transform: translateX(-50%); box-shadow: 0 -7px 0 5px var(--balloon-color); clip-path: polygon(45% 0, 100% 32%, 64% 48%, 58% 100%, 42% 100%, 36% 48%, 0 32%); }
.quickbet-balloon-number { position: relative; z-index: 1; margin-bottom: 4px; font: 800 10px/1 ui-monospace, monospace; opacity: .72; }
.quickbet-balloon-name { position: relative; z-index: 1; display: block; max-width: 100%; font-size: 11px; line-height: 1.25; overflow-wrap: anywhere; }
.quickbet-balloon-burst { position: absolute; display: grid; place-items: center; width: 90px; height: 90px; border-radius: 50%; opacity: 0; transform: scale(.2) rotate(-12deg); background: repeating-conic-gradient(from 0deg, #f8ffd9 0 5deg, transparent 5deg 15deg); filter: drop-shadow(0 0 12px #f8ffd9a8); }
.quickbet-balloon-burst::before { content: ''; position: absolute; inset: 20%; border-radius: 50%; background: #314838; box-shadow: 0 0 18px #d5ef967d; }
.quickbet-balloon-burst b, .quickbet-balloon-burst span { position: relative; z-index: 1; }
.quickbet-balloon-burst b { color: #f8ffd9; font-size: 17px; letter-spacing: .03em; }
.quickbet-balloon-burst span { max-width: 70px; margin-top: -20px; color: #eaf6df; font-size: 9px; font-weight: 700; overflow-wrap: anywhere; }
.quickbet-balloon-safe { position: absolute; right: 1px; top: 4px; z-index: 2; padding: 2px 5px; border-radius: 999px; color: #e8f6d8; background: #31493bb8; font-size: 8px; font-style: normal; font-weight: 800; }
.quickbet-balloon-item.is-winner .quickbet-balloon-body { opacity: 0; transform: scale(1.32); }
.quickbet-balloon-item.is-winner .quickbet-balloon-burst { opacity: 1; transform: scale(1) rotate(0); animation: quickbet-balloon-pop 620ms cubic-bezier(.13,.82,.22,1.2) both; }
.quickbet-visual.is-inflating .quickbet-balloon-body { animation: quickbet-balloon-inflate 760ms ease-in-out var(--balloon-delay) infinite alternate; }
.quickbet-balloon-grid.is-dense { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px 5px; }
.quickbet-balloon-grid.is-dense .quickbet-balloon-item { min-height: 90px; }
.quickbet-balloon-grid.is-dense .quickbet-balloon-body { width: 62px; height: 72px; padding: 9px 5px 14px; }
.quickbet-balloon-grid.is-dense .quickbet-balloon-name { font-size: 9px; }
.quickbet-balloon-caption, .quickbet-card-caption { margin: 14px 0 0; color: #a9bbb6; text-align: center; font-size: 10px; line-height: 1.6; }

/* Lucky cards */
.quickbet-card-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; width: 100%; max-width: 550px; margin: 0 auto; padding: 8px 3px 0; perspective: 900px; }
.quickbet-draw-card { position: relative; min-width: 0; aspect-ratio: .72; perspective: 600px; }
.quickbet-draw-card-inner { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform 650ms cubic-bezier(.18,.72,.24,1); }
.quickbet-draw-card-face { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 10px 6px; border: 1px solid #78909a; border-radius: 12px; backface-visibility: hidden; overflow: hidden; box-shadow: 0 9px 17px #02070843; }
.quickbet-draw-card-back { color: #dce7ff; background: repeating-linear-gradient(135deg, #34465d 0 8px, #29384c 8px 16px); }
.quickbet-draw-card-back::after { content: ''; position: absolute; inset: 8px; border: 1px solid #b9c8ff4a; border-radius: 8px; }
.quickbet-draw-card-back strong { position: relative; z-index: 1; font-size: 30px; line-height: 1; }
.quickbet-draw-card-front { transform: rotateY(180deg); color: #dce8e2; background: linear-gradient(150deg, #293d45, #172b31); }
.quickbet-draw-card.is-winner .quickbet-draw-card-front { border-color: #d5ef96; color: #f4ffd8; background: radial-gradient(circle at 50% 25%, #506343, #294035 63%, #21342e); box-shadow: 0 0 18px #d5ef963f, 0 9px 17px #02070843; }
.quickbet-draw-card-front strong { position: relative; z-index: 1; font-size: clamp(13px, 3.4vw, 18px); line-height: 1.15; }
.quickbet-draw-card-face small { position: relative; z-index: 1; max-width: 100%; color: inherit; font-size: 9px; line-height: 1.3; text-align: center; overflow-wrap: anywhere; opacity: .88; }
.quickbet-card-number { position: absolute; left: 7px; top: 7px; z-index: 1; font: 800 9px/1 ui-monospace, monospace; opacity: .72; }
.quickbet-draw-card.is-revealed .quickbet-draw-card-inner { transform: rotateY(180deg); animation: quickbet-card-reveal 720ms cubic-bezier(.16,.84,.25,1.08) var(--card-delay) both; }
.quickbet-visual.is-shuffling .quickbet-draw-card { animation: quickbet-card-shuffle 540ms ease-in-out var(--card-delay) infinite alternate; }
.quickbet-card-grid.is-dense { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 7px; }
.quickbet-card-grid.is-dense .quickbet-draw-card-face { padding: 7px 4px; border-radius: 9px; }
.quickbet-card-grid.is-dense .quickbet-draw-card-back strong { font-size: 24px; }
.quickbet-card-grid.is-dense .quickbet-draw-card-face small { font-size: 8px; }

.quickbet-particles { position: absolute; z-index: 7; inset: 0; pointer-events: none; overflow: hidden; }
.quickbet-particle {
  position: absolute;
  left: 50%;
  top: 48%;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #d5ef96;
  box-shadow: 0 0 9px currentColor;
  opacity: 0;
  animation: quickbet-particle-burst 900ms cubic-bezier(.12,.74,.22,1) var(--particle-delay) both;
}
.quickbet-particle:nth-child(3n+2) { background: #b9c8ff; border-radius: 2px; }
.quickbet-particle:nth-child(3n) { background: #f4bd95; width: 6px; height: 12px; border-radius: 2px; }

.quickbet-winner {
  position: relative;
  width: 100%;
  margin-top: 13px;
  padding: 18px 16px;
  border: 1px solid #839c60;
  border-radius: 14px;
  text-align: center;
  background: radial-gradient(circle at 50% 0, #46604c 0, #2c4038 58%, #263a34 100%);
  box-shadow: inset 0 1px #ffffff10, 0 0 0 #d5ef9600;
  overflow: hidden;
  animation: quickbet-result-pop 620ms cubic-bezier(.16,.84,.26,1.12) both;
}
.quickbet-winner::before { content: ''; position: absolute; inset: -60% auto -60% -38%; width: 32%; background: linear-gradient(90deg, transparent, #ffffff52, transparent); transform: rotate(15deg) translateX(-250%); pointer-events: none; }
.quickbet-winner.is-celebrating { animation: quickbet-result-pop 620ms cubic-bezier(.16,.84,.26,1.12) both, quickbet-winner-glow 1.05s ease-out both; }
.quickbet-winner.is-celebrating::before { animation: quickbet-winner-sheen 850ms 90ms ease-out both; }
.quickbet-winner span { display: block; position: relative; z-index: 1; color: #b8c8be; font-size: 11px; }
.quickbet-winner strong { display: block; position: relative; z-index: 1; margin: 6px 0 3px; color: #f3f6e9; font-size: clamp(21px, 6vw, 34px); line-height: 1.3; overflow-wrap: anywhere; }
.quickbet-winner.is-celebrating strong { animation: quickbet-winner-name 680ms cubic-bezier(.16,.86,.25,1.18) both; }
.quickbet-winner.is-multi strong { font-size: clamp(18px, 5vw, 27px); line-height: 1.45; }
.quickbet-winner.is-many strong { max-height: 7.2em; padding: 2px 4px; overflow-y: auto; scrollbar-width: thin; }
.quickbet-winner p { position: relative; z-index: 1; color: #d5ef96; font-size: 13px; line-height: 1.6; }
#quickbet-error:empty { display: none; }
#quickbet-error { margin-top: 15px; padding: 12px; border: 1px solid #a58262; border-radius: 9px; color: #ffdbb5; font-size: 12px; line-height: 1.7; }

.quickbet-actions { flex: 0 0 auto; display: grid; grid-template-columns: 1fr; gap: 9px; padding: 14px 20px max(14px, env(safe-area-inset-bottom, 0px)); border-top: 1px solid #3d5559; background: #182a31; }
.quickbet-actions .btn-primary { width: 100%; min-height: 48px; border-color: #b9c8ff; border-radius: 9px; color: #253047; background: #b9c8ff; }
.quickbet-actions .btn-primary:hover { background: #cfdaff; }
.quickbet-actions .btn-secondary { width: 100%; min-height: 44px; padding: 10px 16px; border-radius: 9px; font-size: 12px; }
.quickbet-actions .quickbet-hint { margin: 0; text-align: center; font-size: 10px; }

/* Home card visual for the new games. */
.home-game-quick { --game-accent: #b9c8ff; --game-button-text: #253047; }
.home-game-quick .home-play-button.btn-primary:hover { background: #cfdaff; }
.home-quick-art { background: radial-gradient(circle at 34% 42%, #526b7c, transparent 46%), linear-gradient(135deg, #28434b, #293448); }
.home-quick-wheel {
  position: absolute;
  left: 16%;
  top: 26px;
  width: 126px;
  height: 126px;
  border: 5px solid #e6ecdb;
  border-radius: 50%;
  background: conic-gradient(#d5ef96 0 60deg, #f4bd95 60deg 120deg, #9fd5d2 120deg 180deg, #d8c4ef 180deg 240deg, #f0df9e 240deg 300deg, #a8c4e0 300deg);
  box-shadow: 0 13px 0 #15272f59;
  transform: rotate(-14deg);
}
.home-quick-wheel::before { content: ''; position: absolute; inset: 38%; border-radius: 50%; background: #1b3038; border: 2px solid #eef3e4; }
.home-quick-wheel::after { content: '▼'; position: absolute; left: 50%; top: -20px; transform: translateX(-50%) rotate(14deg); color: #fff0d5; font-size: 20px; }
.home-quick-ladder { position: absolute; right: 11%; top: 29px; width: 110px; height: 126px; opacity: .92; }
.home-quick-ladder i { position: absolute; display: block; border-radius: 2px; background: #c7d9d4; }
.home-quick-ladder .v1 { left: 12%; top: 0; width: 4px; height: 100%; }
.home-quick-ladder .v2 { left: 49%; top: 0; width: 4px; height: 100%; }
.home-quick-ladder .v3 { right: 12%; top: 0; width: 4px; height: 100%; }
.home-quick-ladder .h1 { left: 14%; top: 25%; width: 37%; height: 4px; transform: rotate(-7deg); }
.home-quick-ladder .h2 { left: 50%; top: 47%; width: 37%; height: 4px; transform: rotate(6deg); }
.home-quick-ladder .h3 { left: 14%; top: 69%; width: 37%; height: 4px; transform: rotate(5deg); }
.home-quick-ladder::after { content: '☕'; position: absolute; right: 1%; bottom: -26px; font-size: 22px; }
.home-quick-art .home-art-index { color: #e7ebff; background: #303e59; }

@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .home-game-quick:hover .home-quick-wheel,
  .home-game-quick:focus-within .home-quick-wheel { animation: quickbet-home-wheel 2.2s cubic-bezier(.16,.75,.22,1) infinite; }
  .home-game-quick:hover .home-quick-ladder,
  .home-game-quick:focus-within .home-quick-ladder { animation: quickbet-home-ladder 1.6s ease-in-out infinite alternate; }
}

@media (max-width: 619px) {
  .quickbet-wheel-grid:not(.is-single) > .quickbet-wheel-wrap:last-child:nth-child(odd) { grid-column: 1 / -1; }
}

@media (min-width: 620px) {
  .quickbet-wheel-grid:not(.is-single) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .quickbet-wheel-grid:not(.is-single) .quickbet-wheel-wrap { max-width: 185px; }
}

@media (min-width: 1040px) {
  .home-games { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .home-game h2 { font-size: 24px; }
  .home-game-description { font-size: 13px; }
}

@media (max-width: 600px) {
  .quickbet-wheel-grid .quickbet-wheel.is-dense .quickbet-wheel-label { font-size: 24px; }
  .quickbet-ladder-wrap.is-dense .quickbet-ladder-viewport { overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; }
  .quickbet-ladder-wrap.is-dense .quickbet-ladder-svg:not(.quickbet-ladder-lens-svg) { min-width: 520px; height: 260px; min-height: 260px; max-height: 260px; }
  .quickbet-ladder-wrap.is-dense .quickbet-ladder-caption { margin-top: 10px; }
  .quickbet-ladder-scroll-hint { display: block; margin: 0 0 8px; color: #c7d7ce; font-size: 11px; line-height: 1.6; }
}

@media (max-width: 760px) {
  .home-quick-wheel { left: 15px; top: 28px; width: 72px; height: 72px; border-width: 3px; }
  .home-quick-wheel::after { top: -15px; font-size: 15px; }
  .home-quick-ladder { right: 7px; top: 43px; width: 53px; height: 82px; }
  .home-quick-ladder i { transform: none !important; }
  .home-quick-ladder .v1, .home-quick-ladder .v2, .home-quick-ladder .v3 { width: 3px; }
  .home-quick-ladder .h1, .home-quick-ladder .h2, .home-quick-ladder .h3 { height: 3px; }
  .home-quick-ladder::after { bottom: -23px; font-size: 17px; }
}

@media (max-width: 420px) {
  .quickbet-balloon-grid, .quickbet-card-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 6px; }
  .quickbet-balloon-grid.is-dense, .quickbet-card-grid.is-dense { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px 4px; }
  .quickbet-balloon-body { width: 72px; height: 84px; }
  .quickbet-balloon-grid.is-dense .quickbet-balloon-body { width: 55px; height: 65px; }
  .quickbet-content { padding: 16px; }
  #quickBetModal .modal-header { padding: 14px 16px; }
  .quickbet-actions { padding-left: 16px; padding-right: 16px; }
  .quickbet-names { grid-template-columns: 1fr; gap: 7px; }
  .quickbet-visual { min-height: 270px; padding-left: 2px; padding-right: 2px; }
  .quickbet-wheel-grid { gap: 10px 7px; }
  .quickbet-wheel-grid.is-single .quickbet-wheel-wrap { width: min(100%, 300px); }
  .quickbet-wheel-grid:not(.is-single) .quickbet-wheel-wrap { max-width: 154px; padding: 4px; }
  .quickbet-wheel-grid.is-many .quickbet-wheel-wrap { max-width: 142px; }
  .quickbet-wheel-label { font-size: 10px; }
  .quickbet-wheel-grid:not(.is-single) .quickbet-wheel-label { font-size: 8px; }
  .quickbet-ladder-svg { min-height: 225px; }
  .quickbet-ladder-line { stroke-width: 6; }
  .quickbet-ladder-trace { stroke-width: 12; }
  .quickbet-ladder-trace-glow { stroke-width: 27; }
  .quickbet-ladder-svg.is-dense .quickbet-ladder-line { stroke-width: 3.2; }
  .quickbet-ladder-svg.is-dense .quickbet-ladder-trace { stroke-width: 7; }
  .quickbet-ladder-svg.is-dense .quickbet-ladder-trace-glow { stroke-width: 17; }
  .quickbet-ladder-svg.is-dense .quickbet-ladder-number { font-size: 19px; }
  .quickbet-ladder-svg.is-dense .quickbet-ladder-pass { font-size: 14px; }
  .quickbet-ladder-svg.is-dense .quickbet-ladder-coffee { font-size: 24px; }
}

@keyframes quickbet-ambient-spin {
  to { transform: rotate(360deg) scale(.96); }
}

@keyframes quickbet-stage-sheen {
  0% { transform: translate3d(-180%,0,0) rotate(17deg); opacity: 0; }
  28% { opacity: .65; }
  65% { opacity: .32; }
  100% { transform: translate3d(560%,0,0) rotate(17deg); opacity: 0; }
}

@keyframes quickbet-wheel-breathe {
  from { transform: scale(.988); }
  to { transform: scale(1.012); }
}

@keyframes quickbet-wheel-aura-spin {
  to { transform: scale(1.04) rotate(360deg); }
}

@keyframes quickbet-wheel-orbit-spin {
  to { transform: rotate(360deg); }
}

@keyframes quickbet-wheel-sheen {
  0% { transform: translate3d(-95%,0,0) rotate(-8deg); opacity: 0; }
  25% { opacity: .75; }
  100% { transform: translate3d(95%,0,0) rotate(-8deg); opacity: 0; }
}

@keyframes quickbet-pointer-tick {
  from { transform: translateX(-50%) rotate(-7deg) scale(1); }
  to { transform: translateX(-50%) rotate(7deg) scale(1.08); }
}

@keyframes quickbet-runner-halo {
  0% { transform: scale(.62); opacity: .82; }
  75%, 100% { transform: scale(1.58); opacity: 0; }
}

@keyframes quickbet-result-pop {
  0% { opacity: .12; transform: translateY(12px) scale(.94); }
  58% { opacity: 1; transform: translateY(-3px) scale(1.025); }
  82% { transform: translateY(1px) scale(.995); }
  100% { opacity: 1; transform: none; }
}

@keyframes quickbet-winner-glow {
  0% { box-shadow: inset 0 1px #ffffff10, 0 0 0 #d5ef9600; }
  35% { box-shadow: inset 0 1px #ffffff24, 0 0 26px #d5ef9657, 0 0 52px #b9c8ff26; }
  100% { box-shadow: inset 0 1px #ffffff10, 0 0 0 #d5ef9600; }
}

@keyframes quickbet-winner-sheen {
  from { transform: rotate(15deg) translateX(-250%); opacity: 0; }
  28% { opacity: .82; }
  to { transform: rotate(15deg) translateX(650%); opacity: 0; }
}

@keyframes quickbet-winner-name {
  0% { transform: scale(.78); opacity: .35; letter-spacing: -.04em; }
  62% { transform: scale(1.09); opacity: 1; letter-spacing: .015em; }
  100% { transform: scale(1); opacity: 1; letter-spacing: 0; }
}

@keyframes quickbet-particle-burst {
  0% { opacity: 0; transform: translate3d(-50%,-50%,0) scale(.25) rotate(0); }
  16% { opacity: 1; }
  72% { opacity: .92; }
  100% { opacity: 0; transform: translate3d(calc(-50% + var(--particle-x)), calc(-50% + var(--particle-y)), 0) scale(.72) rotate(var(--particle-rotate)); }
}

@keyframes quickbet-home-wheel {
  0%, 100% { transform: rotate(-14deg) scale(1); }
  50% { transform: rotate(346deg) scale(1.035); }
}

@keyframes quickbet-home-ladder {
  from { transform: translateY(0); filter: drop-shadow(0 0 0 #d5ef9600); }
  to { transform: translateY(-4px); filter: drop-shadow(0 4px 8px #d5ef9638); }
}

@keyframes quickbet-balloon-inflate {
  0% { transform: translateY(3px) scale(.88,.9) rotate(-2deg); }
  55% { transform: translateY(-3px) scale(1.04,1.08) rotate(2deg); }
  100% { transform: translateY(-7px) scale(1.13,1.2) rotate(-1deg); }
}

@keyframes quickbet-balloon-pop {
  0% { opacity: 0; transform: scale(.18) rotate(-18deg); }
  58% { opacity: 1; transform: scale(1.18) rotate(4deg); }
  100% { opacity: 1; transform: scale(1) rotate(0); }
}

@keyframes quickbet-card-shuffle {
  0% { transform: translate3d(-6px,3px,0) rotate(-4deg) scale(.96); }
  100% { transform: translate3d(6px,-4px,0) rotate(4deg) scale(1.02); }
}

@keyframes quickbet-card-reveal {
  0% { transform: rotateY(0deg) scale(.94); }
  66% { transform: rotateY(190deg) scale(1.04); }
  100% { transform: rotateY(180deg) scale(1); }
}

/* Keep the game readable in lighter performance modes without expensive decorative paint. */
body:is([data-performance="low"], [data-performance="ultraLow"], .low-performance-mode) .quickbet-visual::before,
body:is([data-performance="low"], [data-performance="ultraLow"], .low-performance-mode) .quickbet-visual::after,
body:is([data-performance="low"], [data-performance="ultraLow"], .low-performance-mode) :is(.quickbet-wheel-aura, .quickbet-wheel-orbit, .quickbet-wheel-sheen, .quickbet-ladder-trace-glow) {
  display: none;
}

body:is([data-performance="low"], [data-performance="ultraLow"], .low-performance-mode)
:is(.quickbet-wheel, .quickbet-wheel-pointer, .quickbet-ladder-trace, .quickbet-ladder-runner, .quickbet-ladder-number.is-winner, .quickbet-ladder-coffee, .quickbet-balloon-burst) {
  filter: none;
}

body:is([data-performance="low"], [data-performance="ultraLow"], .low-performance-mode)
:is(.quickbet-balloon-body, .quickbet-draw-card-face, .quickbet-draw-card.is-winner .quickbet-draw-card-front) {
  box-shadow: none;
}

body[data-performance="ultraLow"] .quickbet-particles {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .quickbet-visual::before,
  .quickbet-visual::after,
  .quickbet-wheel-wrap,
  .quickbet-wheel-aura,
  .quickbet-wheel-orbit,
  .quickbet-wheel-sheen,
  .quickbet-wheel-pointer,
  .quickbet-wheel,
  .quickbet-ladder-trace,
  .quickbet-ladder-trace-glow,
  .quickbet-ladder-runner-halo,
  .quickbet-balloon-body,
  .quickbet-balloon-burst,
  .quickbet-draw-card,
  .quickbet-draw-card-inner,
  .quickbet-winner,
  .quickbet-winner::before,
  .quickbet-winner strong,
  .home-quick-wheel,
  .home-quick-ladder { transition: none !important; animation: none !important; }
  .quickbet-particles { display: none !important; }
}

/* Interactive ladder: player-by-player suspense and traced routes. */
.quickbet-ladder-intro {
  margin: 0 0 10px; color: #e3eddf; font-size: 12px;
  line-height: 1.5; text-align: center; word-break: keep-all;
}
.quickbet-ladder-players {
  display: flex; gap: 8px; width: 100%; padding: 3px 2px 12px;
  overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: thin;
}
.quickbet-ladder-player {
  display: flex; flex: 0 0 106px; flex-direction: column; align-items: center;
  justify-content: center; gap: 4px; min-height: 68px; padding: 7px;
  border: 1px solid #587279; border-bottom: 3px solid var(--player-color);
  border-radius: 10px; background: #203640; color: #eaf4ee;
  transition: background .18s ease, transform .18s ease;
  cursor: pointer;
}
.quickbet-ladder-player b { color: var(--player-color); font-size: 12px; }
.quickbet-ladder-player span {
  width: 100%; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; font-size: 11px; font-weight: 700; text-align: center;
}
.quickbet-ladder-player small { color: #becfc9; font-size: 10px; }
.quickbet-ladder-player.is-coffee { background: #50402f; border-color: #e3b883; }
.quickbet-ladder-player.is-coffee small { color: #ffe9b2; }
.quickbet-ladder-player.is-safe { background: #213b34; border-color: #8ec9a0; }
.quickbet-ladder-player.is-safe small { color: #b8f3c4; }
.quickbet-ladder-player:disabled { cursor: default; opacity: 1; }
.quickbet-ladder-player:focus-visible, .quickbet-ladder-action:focus-visible {
  outline: 3px solid #e5ff9d; outline-offset: 2px;
}
@media (hover: hover) {
  .quickbet-ladder-player:not(:disabled):hover { background: #34505b; transform: translateY(-2px); }
}
.quickbet-ladder-route { opacity: 0; pointer-events: none; }
.quickbet-ladder-route.is-revealed, .quickbet-ladder-route.is-active { opacity: 1; }
.quickbet-ladder-route:not(.is-active) .quickbet-ladder-runner-halo { animation: none; }
.quickbet-ladder-route.is-active .quickbet-ladder-runner { filter: drop-shadow(0 0 10px var(--trace-color)); }
.quickbet-ladder-mascot {
  fill: var(--trace-color); font: 900 19px/1 system-ui, sans-serif;
  filter: drop-shadow(0 0 6px var(--trace-color));
}
.quickbet-ladder-mystery { fill: #d2dbdc; font: 800 24px/1 system-ui, sans-serif; }
.quickbet-ladder-controls {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  margin-top: 14px;
}
.quickbet-ladder-action {
  min-height: 43px; padding: 9px 10px; border: 1px solid #729a9b;
  border-radius: 9px; color: #f0f7ec; background: #294951;
  font-size: 12px; font-weight: 750; line-height: 1.4;
}
.quickbet-ladder-action.is-next { color: #243039; background: #d5ef96; border-color: #d5ef96; }
.quickbet-ladder-action.is-all { color: #283446; background: #b9c8ff; border-color: #b9c8ff; }
.quickbet-ladder-controls.is-duo { grid-template-columns: minmax(0, 1fr); max-width: 520px; margin-inline: auto; width: 100%; }
.quickbet-ladder-controls.is-duo .quickbet-ladder-action.is-duo {
  min-height: 51px; color: #1f372d; background: #d5ef96; border-color: #e1f5b0;
  font-size: 14px; font-weight: 850;
}
.quickbet-ladder-player.is-pair { cursor: default; }
@media (hover: hover) {
  .quickbet-ladder-player.is-pair:hover { background: #203640; transform: none; }
}
.quickbet-ladder-action.is-sound {
  grid-column: 1 / -1; justify-self: center; min-height: 34px;
  border-color: #3c5961; background: transparent; color: #c5d5cd;
  font-weight: 600; font-size: 11px;
}
.quickbet-ladder-action:disabled { opacity: .48; cursor: default; }
.quickbet-ladder-progress { margin: 9px 0 0; color: #b7d7d3; text-align: center; font-size: 11px; }
@media (max-width: 420px) {
  .quickbet-ladder-player { flex-basis: 89px; min-height: 64px; }
  .quickbet-ladder-action { font-size: 11px; }
  .quickbet-ladder-mystery { font-size: 23px; }
}
@media (prefers-reduced-motion: reduce) {
  .quickbet-ladder-player { transition: none; }
  .quickbet-ladder-route .quickbet-ladder-runner-halo { animation: none !important; }
}

/* ---- css/modules/local-dice.css ---- */
#diceModal [hidden] { display: none !important; }
#diceModal { padding: max(12px, env(safe-area-inset-top, 0px)) 12px max(12px, env(safe-area-inset-bottom, 0px)); }
#diceModal .dice-panel { display: flex; flex-direction: column; width: 100%; max-width: 600px; max-height: calc(100vh - 48px); max-height: calc(100dvh - 48px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)); padding: 0; margin: 12px auto; overflow: hidden; animation: none; transform: none; }
#diceModal .modal-header { flex: 0 0 auto; position: static; margin: 0; padding: 16px 20px; gap: 16px; }
#diceModal .modal-header h2 { font-size: 21px; line-height: 1.4; }
#dice-close { width: 44px; height: 44px; flex: 0 0 44px; padding: 0; background: #21373b; }
.dice-content { min-height: 0; padding: 20px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.dice-play-modes { display: flex; align-items: stretch; gap: 5px; padding: 4px; border: 1px solid #48605f; border-radius: 10px; background: #12262d; }
.dice-play-modes > span, .dice-play-modes > button { display: flex; align-items: center; justify-content: center; flex: 1; min-height: 44px; gap: 9px; padding: 8px 10px; border-radius: 7px; font-size: 12px; line-height: 1.5; text-align: center; word-break: keep-all; }
.dice-play-modes .is-current { color: #392c23; background: #f4bd95; font-weight: 700; }
.dice-play-modes button { color: #c8d9d2; }
.dice-play-modes button:hover { background: #2b4248; }
.dice-play-modes button span:last-child { font-size: 18px; }
.dice-intro { margin: 17px 0 20px; color: #b7c8c3; font-size: 13px; line-height: 1.8; word-break: keep-all; }
.dice-settings { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 12px; }
.dice-field { min-width: 0; }
.dice-field label { display: block; margin-bottom: 7px; color: #deeadf; font-size: 12px; font-weight: 600; }
.dice-rule-field { grid-column: 1 / -1; }
#diceModal select, #diceModal input { display: block; width: 100%; min-width: 0; min-height: 46px; padding: 10px 12px; border: 1px solid #4a6264; border-radius: 8px; background: #11262d; color: #f0f3e9; font: inherit; font-size: 16px; box-shadow: none; color-scheme: dark; }
#diceModal select { cursor: pointer; }
#diceModal :is(select,input):focus-visible { border-color: #f4bd95; outline: 2px solid #f4bd95; outline-offset: 2px; }
.dice-hint { margin-top: 10px; color: #a8bdb6; font-size: 11px; line-height: 1.7; overflow-wrap: anywhere; }
.dice-card-guide { margin-top: 14px; padding: 12px; border: 1px solid #546051; border-radius: 8px; color: #d1d7b8; font-size: 12px; line-height: 1.8; }
.dice-card-guide summary { display: flex; align-items: center; min-height: 44px; cursor: pointer; }
.dice-card-guide p { margin-top: 10px; }
.dice-roll-stage { position: relative; isolation: isolate; display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 8px; min-height: 128px; margin-bottom: 14px; padding: 20px 8px; border: 1px solid #426661; border-radius: 18px; background: radial-gradient(ellipse at center,#33584e,#122c2c); overflow: hidden; }
.dice-roll-stage:not([hidden]) { animation: dice-stage-breathe 1100ms ease-out both; }
.dice-roll-stage:not([hidden])::before {
  content: '';
  position: absolute;
  z-index: -1;
  inset: -35%;
  background: radial-gradient(circle at 50% 55%,#d5ef9629 0 18%,transparent 52%);
  transform: scale(.65);
  opacity: 0;
  animation: dice-stage-glow 1100ms ease-out both;
  pointer-events: none;
}
.dice-result.is-hwatu .dice-result-top { flex-wrap: wrap; gap: 5px 10px; }
.dice-result.is-hwatu .dice-result-score { max-width: 100%; }
.dice-names-title { margin: 24px 0 0; color: #e3ebdc; font-size: 14px; }
.dice-names { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 12px; }
.dice-name-field { display: flex; align-items: center; gap: 9px; min-width: 0; padding: 0 10px; border: 1px solid #3e575b; border-radius: 8px; background: #14272f; }
.dice-name-number { color: #bfbd9f; font: 11px ui-monospace, monospace; }
#diceModal .dice-name-field input { border: 0; padding-left: 0; padding-right: 0; background: none; }
#diceModal .dice-name-field input::placeholder { color: #90a8a7; font-size: 13px; }
.dice-name-field:focus-within { border-color: #f4bd95; }
.dice-actions { flex: 0 0 auto; display: grid; grid-template-columns: 1fr; gap: 9px; padding: 14px 20px max(14px,env(safe-area-inset-bottom,0px)); border-top: 1px solid #3d5559; background: #182a31; }
.dice-actions .btn-primary { width: 100%; min-height: 48px; background: #f4bd95; color: #392c23; border-color: #f4bd95; border-radius: 9px; }
.dice-actions .btn-primary:hover { background: #ffd2b2; }
.dice-actions .btn-secondary { width: 100%; min-height: 44px; padding: 10px 16px; border-radius: 9px; font-size: 12px; }
.dice-actions .dice-hint { margin: 0; text-align: center; font-size: 10px; }
.dice-result-heading { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-top: 20px; }
#dice-round { margin-bottom: 4px; color: #c8bca8; font-size: 11px; }
#dice-results-title { color: #f0f3e9; font-size: 21px; line-height: 1.5; }
.dice-local-badge { flex-shrink: 0; padding: 5px 8px; color: #c8dac9; background: #2b4644; border-radius: 5px; font-size: 10px; }
#dice-status { min-height: 1.7em; margin: 14px 0 12px; color: #c9d7c8; font-size: 12px; line-height: 1.7; }
#dice-results { display: grid; gap: 9px; margin: 0; padding: 0; list-style: none; }
.dice-result { display: flex; gap: 12px; padding: 13px 12px; border: 1px solid #3e5659; border-radius: 12px; background: #142930; }
.dice-result.is-reveal { animation: dice-result-arrive 480ms cubic-bezier(.18,.78,.25,1.12) both; }
.dice-result.is-reveal .dice-result-score { animation: dice-result-score-pop 620ms cubic-bezier(.18,.78,.25,1.25) both; }
.dice-result.is-winner { border-color: #d5ef96; background: #30483b; box-shadow: inset 0 0 24px #d5ef9610, 0 0 12px #d5ef961f; }
.dice-result-rank { flex: 0 0 34px; padding-top: 1px; color: #c5ceb0; font-size: 12px; font-weight: 700; }
.dice-result-main { flex: 1; min-width: 0; }
.dice-result-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 10px; }
.dice-result-name { min-width: 0; color: #e3ebdc; font-size: 13px; overflow-wrap: anywhere; }
.dice-winner-badge { flex: 0 0 auto; margin-left: auto; padding: 3px 7px; border: 1px solid #d5ef9680; border-radius: 999px; color: #ecffc2; background: #455a38; font-size: 9px; font-style: normal; font-weight: 800; letter-spacing: .04em; line-height: 1.4; }
.dice-result-score { flex-shrink: 0; max-width: 46%; color: #f4cd9d; font-size: 15px; line-height: 1.5; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.dice-faces { display: flex; gap: 8px; flex-wrap: wrap; }
.dice-face { display: grid; place-items: center; width: 38px; height: 38px; border: 1px solid #f6f1e0; border-radius: 9px; color: #2e453c; background: #e9eed9; box-shadow: 0 3px 0 #738d7b; font: 700 20px/1 ui-monospace, monospace; }
#dice-error:empty { display: none; }
#dice-error { margin-top: 16px; padding: 12px; border: 1px solid #a58262; border-radius: 9px; color: #ffdbb5; font-size: 12px; line-height: 1.7; }
#party-local { width: 100%; margin: 0 0 20px; font-size: 12px !important; }
@media (max-width: 420px) {
  .dice-content { padding: 16px; }
  .dice-settings > .dice-field:first-child { grid-column: 1 / -1; }
  #diceModal .modal-header { padding: 14px 16px; }
  .dice-actions { padding-left: 16px; padding-right: 16px; }
  .dice-play-modes > span, .dice-play-modes > button { padding: 8px 6px; font-size: 11px; }
  .dice-names { grid-template-columns: 1fr; gap: 7px; }
  .dice-result { gap: 8px; padding: 12px 9px; }
  .dice-result-rank { flex-basis: 29px; }
  .dice-result-top { gap: 8px; }
  .dice-result-score { font-size: 13px; }
  .dice-face { width: 32px; height: 32px; font-size: 18px; border-radius: 7px; }
}

@keyframes dice-stage-breathe {
  0% { border-color: #426661; box-shadow: inset 0 0 0 transparent; }
  42% { border-color: #8eaa78; box-shadow: inset 0 0 34px #d5ef9614; }
  100% { border-color: #426661; box-shadow: inset 0 0 0 transparent; }
}
@keyframes dice-stage-glow {
  0% { opacity: 0; transform: scale(.65); }
  28% { opacity: 1; }
  72% { opacity: .45; transform: scale(1.05); }
  100% { opacity: 0; transform: scale(1.2); }
}
@keyframes dice-result-arrive {
  0% { opacity: .35; transform: translateY(8px) scale(.985); }
  58% { opacity: 1; transform: translateY(-1px) scale(1.006); }
  100% { opacity: 1; transform: none; }
}
@keyframes dice-result-score-pop {
  0%,30% { opacity: .45; transform: scale(.82); }
  62% { opacity: 1; transform: scale(1.08); }
  100% { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .dice-roll-stage:not([hidden]),
  .dice-roll-stage:not([hidden])::before,
  .dice-result.is-reveal,
  .dice-result.is-reveal .dice-result-score {
    animation: none;
  }
}


/* Tactile 3D dice table: a throw skitters, tumbles, hits the felt and settles.
   The real result is chosen by DiceRules before this visual animation begins. */
#diceModal .dice-roll-stage.is-dice-arena {
  display: block;
  min-height: 292px;
  margin: 15px 0 19px;
  padding: 0;
  border: 1px solid #a78e6d;
  border-radius: 25px;
  background: #173f35;
  box-shadow: 0 18px 38px #07171470, inset 0 0 0 5px #071f20,
              inset 0 0 0 7px #b79a6955;
  overflow: hidden;
  animation: none;
}
#diceModal .dice-roll-stage.is-dice-arena::before { display: none; }
.dice-arena-board {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 292px;
  padding: 20px 16px 16px;
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(ellipse 65% 70% at 50% 70%,#4e876447,transparent 95%),
    radial-gradient(ellipse 85% 45% at 60% -20%,#e3dfb32b,transparent 95%),
    repeating-linear-gradient(110deg,transparent 0 7px,#e5d2a803 8px 10px),
    linear-gradient(155deg,#265447,#164438 65%,#10392f);
}
.dice-arena-board::before {
  content: '';
  position: absolute;
  z-index: -1;
  inset: 10px;
  border: 1px solid #e2d2a51a;
  border-radius: 18px;
  pointer-events: none;
}
.dice-arena-board::after {
  content: '';
  position: absolute;
  z-index: -1;
  inset: 0;
  background: radial-gradient(circle at 50% 85%, transparent 26%, #031b1e62 100%);
  pointer-events: none;
}
.dice-arena-caption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 26px;
  color: #ffebbf;
  text-shadow: 0 2px 4px #09221c;
  font-weight: 750;
  font-size: 13px;
  letter-spacing: .01em;
}
.dice-arena-caption-name { overflow-wrap: anywhere; }
.dice-arena-caption-result { color: #fff5d8; font-size: 19px; font-variant-numeric: tabular-nums; }
.dice-arena-field {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  justify-content: center;
  flex-wrap: nowrap;
  gap: clamp(12px,5vw,46px);
  max-width: 600px;
  width: 100%;
  margin: 2px auto 8px;
  perspective: 720px;
}
.dice-arena-slot {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 1 79px;
  width: 79px;
  height: 110px;
  min-width: 0;
  --arena-x: 0px;
  --arena-z: 0deg;
  --arena-spin: 1;
}
.dice-arena-slot--1 { --arena-x: -60px; --arena-z: -33deg; --arena-spin: 1; }
.dice-arena-slot--2 { --arena-x: 65px; --arena-z: 31deg; --arena-spin: -1; }
.dice-arena-slot--3 { --arena-x: -42px; --arena-z: 23deg; --arena-spin: -1; }
.dice-arena-slot--4 { --arena-x: 75px; --arena-z: -28deg; --arena-spin: 1; }
.dice-arena-board--2 .dice-arena-slot:nth-child(odd) { --arena-x: 75px; --arena-z: 27deg; }
.dice-arena-board--2 .dice-arena-slot:nth-child(even) { --arena-x: -65px; --arena-z: -35deg; }
.dice-arena-board--3 .dice-arena-slot:nth-child(odd) { --arena-x: -90px; --arena-z: -25deg; }
.dice-arena-board--3 .dice-arena-slot:nth-child(even) { --arena-x: 50px; --arena-z: 42deg; }
.dice-arena-slot .game-die {
  --die-size: 68px;
  --die-half: 34px;
  margin: 0;
  perspective: 480px;
  filter: drop-shadow(0 8px 5px #031c1988);
}
.dice-arena-slot .game-die .game-die-face {
  border: 2px solid #fffdf3;
  border-radius: 9px;
  background: linear-gradient(140deg,#fffef5 3%,#f2f3e4 55%,#d0d8be);
  box-shadow: inset 2px 3px 7px #ffffffba, inset -2px -3px 8px #7c87774b,0 2px 2px #112a2499;
  padding: 11px;
  gap: 3px;
}
.dice-arena-slot .game-die .game-die-pip {
  max-width: 12px;
  background: radial-gradient(circle at 35% 30%,#33474a,#091c25);
  box-shadow: inset 0 2px 2px #0009,0 1px 1px #fff8;
}
/* The arena has its own dark pip style; override it for face 1. */
.dice-arena-slot .game-die .game-die-face--one .game-die-pip {
  background: radial-gradient(circle at 35% 30%, #f56762, #b82129 78%);
  box-shadow: inset 0 2px 2px #73121980, 0 1px 1px #fff8;
}
.dice-arena-slot .game-die .game-die-face--front { transform: translateZ(var(--die-half)); }
.dice-arena-slot .game-die.is-rolling .game-die-motion {
  animation: dice-arena-hop 2220ms cubic-bezier(.2,.6,.24,1) both;
  animation-delay: calc(var(--piece-index) * 78ms);
}
.dice-arena-slot .game-die.is-rolling .game-die-cube {
  animation: dice-arena-tumble 2220ms cubic-bezier(.14,.56,.24,1) both;
  animation-delay: calc(var(--piece-index) * 78ms);
}
.dice-arena-slot .game-die.is-rolling::after {
  animation: dice-arena-shadow 2220ms ease both;
  animation-delay: calc(var(--piece-index) * 78ms);
  background: #051510a8;
  filter: blur(6px);
}
.dice-arena-slot .game-die.is-rolling::before {
  animation: dice-arena-ring 2220ms ease both;
  animation-delay: calc(var(--piece-index) * 78ms);
  border-color: #f1e7b9bd;
}
@keyframes dice-arena-hop {
  0%   { transform: translate3d(var(--arena-x),-100px,0) rotateZ(var(--arena-z)) scale(.66); }
  17%  { transform: translate3d(-20px,-38px,0) rotateZ(-18deg) scale(1.11); }
  32%  { transform: translate3d(13px,23px,0) rotateZ(13deg) scale(1.07,.88); }
  47%  { transform: translate3d(-10px,-52px,0) rotateZ(-12deg) scale(1.03); }
  63%  { transform: translate3d(8px,12px,0) rotateZ(6deg) scale(1.05,.94); }
  74%  { transform: translate3d(-3px,-23px,0) rotateZ(-4deg) scale(1); }
  85%  { transform: translate3d(2px,5px,0) rotateZ(2deg) scale(1.03,.97); }
  94%  { transform: translate3d(0,-5px,0) rotateZ(-1deg); }
  100% { transform: none; }
}
@keyframes dice-arena-tumble {
  0% { transform: rotateX(990deg) rotateY(-760deg) rotateZ(210deg); }
  25% { transform: rotateX(710deg) rotateY(-500deg) rotateZ(-145deg); }
  48% { transform: rotateX(470deg) rotateY(-340deg) rotateZ(120deg); }
  65% { transform: rotateX(245deg) rotateY(-177deg) rotateZ(-62deg); }
  79% { transform: rotateX(85deg) rotateY(-53deg) rotateZ(20deg); }
  90% { transform: rotateX(-14deg) rotateY(9deg) rotateZ(-4deg); }
  96% { transform: rotateX(5deg) rotateY(-3deg) rotateZ(2deg); }
  100% { transform: none; }
}
@keyframes dice-arena-shadow {
  0% { opacity: .12; transform: scale(.3); filter: blur(12px); }
  32% { opacity: .95; transform: scale(1.3); filter: blur(2px); }
  47% { opacity: .17; transform: scale(.5); filter: blur(10px); }
  63% { opacity: .8; transform: scale(1.08); filter: blur(3px); }
  74% { opacity: .3; transform: scale(.7); filter: blur(7px); }
  100% { opacity: .82; transform: scale(1); filter: blur(4px); }
}
@keyframes dice-arena-ring {
  0%,27% { opacity: 0; transform: translateX(-50%) scale(.2); }
  32% { opacity: .8; transform: translateX(-50%) scale(.6); }
  43% { opacity: 0; transform: translateX(-50%) scale(1.7); }
  60% { opacity: 0; transform: translateX(-50%) scale(.2); }
  64% { opacity: .55; transform: translateX(-50%) scale(.7); }
  76%,100% { opacity: 0; transform: translateX(-50%) scale(1.7); }
}
/* Finished dice stay on the table, showing exactly the scored face. */
.dice-roll-stage.is-arena-finished .game-die.is-rolling .game-die-motion,
.dice-roll-stage.is-arena-finished .game-die.is-rolling .game-die-cube,
.dice-roll-stage.is-arena-finished .game-die.is-rolling::after,
.dice-roll-stage.is-arena-finished .game-die.is-rolling::before {
  animation: none;
  transform: none;
}
.dice-roll-stage.is-arena-finished .game-die.is-rolling::after { transform: scaleX(.9); opacity: .8; }
.dice-arena-floor-line {
  position: absolute;
  left: 12%; right: 12%; bottom: 14px;
  height: 1px;
  background: linear-gradient(90deg,transparent,#d2b77e51,transparent);
}
@media (max-width: 510px) {
  #diceModal .dice-roll-stage.is-dice-arena,.dice-arena-board { min-height: 245px; }
  .dice-arena-board { padding: 15px 12px; }
  .dice-arena-slot { flex-basis: 60px; height: 90px; }
  .dice-arena-field { gap: clamp(2px,2vw,12px); }
  .dice-arena-slot .game-die { --die-size: 50px; --die-half: 25px; }
  .dice-arena-slot .game-die .game-die-face { padding: 8px; gap: 2px; border-radius: 6px; }
  .dice-arena-slot .game-die .game-die-pip { max-width: 8px; }
  .dice-arena-caption { font-size: 12px; }
  .dice-arena-caption-result { font-size: 15px; }
}
@media (prefers-reduced-motion: reduce) {
  .dice-arena-slot .game-die.is-rolling .game-die-motion,
  .dice-arena-slot .game-die.is-rolling .game-die-cube,
  .dice-arena-slot .game-die.is-rolling::before,
  .dice-arena-slot .game-die.is-rolling::after { animation: none !important; transform: none; }
  .dice-arena-slot .game-die.is-rolling::after { transform: scaleX(.9); opacity: .8; }
}

/* Multi-player dice arena: every participant has an independent 3D throw. */
#diceModal .dice-roll-stage.is-dice-arena {
  min-height: 0;
  padding: 11px;
}
.dice-arena-grid {
  display: grid;
  grid-template-columns: repeat(2,minmax(0,1fr));
  align-items: stretch;
  gap: 11px;
  width: 100%;
  padding: 3px;
  isolation: isolate;
}
.dice-arena-grid--solo { grid-template-columns: minmax(0,1fr); max-width: 510px; margin: 0 auto; }
.dice-arena-grid--medium { grid-template-columns: repeat(3,minmax(0,1fr)); }
.dice-arena-grid--packed { grid-template-columns: repeat(4,minmax(0,1fr)); gap: 8px; }
.dice-arena-participant {
  --tile-die-size: 60px;
  --tile-die-half: 30px;
  --tile-face-pad: 8px;
  --tile-pip-size: 9px;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-width: 0;
  min-height: 161px;
  padding: 13px 14px 9px;
  overflow: hidden;
  isolation: isolate;
  border: 1px solid #91b59b65;
  border-radius: 16px;
  background: radial-gradient(ellipse at 48% 62%,#7ca16a36,transparent 67%),linear-gradient(155deg,#295849,#173d34 74%,#0f312b);
  box-shadow: inset 0 0 0 1px #ffffff08,0 8px 18px #0319145c;
}
.dice-arena-participant::before {
  content: '';
  position: absolute;
  inset: 7px;
  border: 1px solid #e3d8aa14;
  border-radius: 11px;
  pointer-events: none;
}
.dice-arena-participant--2 { background: radial-gradient(ellipse at 48% 62%,#8ea97b33,transparent 67%),linear-gradient(155deg,#32564d,#1e3e3f 74%,#132f35); }
.dice-arena-participant--3 { background: radial-gradient(ellipse at 48% 62%,#9faa6b2e,transparent 67%),linear-gradient(155deg,#345749,#284239 74%,#172d31); }
.dice-arena-participant--4 { background: radial-gradient(ellipse at 48% 62%,#7cbca02d,transparent 67%),linear-gradient(155deg,#29564a,#153c3a 74%,#102e35); }
.dice-arena-participant.is-winner {
  border-color: #ffe5a8;
  box-shadow: inset 0 0 0 1px #ffd987a6, 0 0 22px #ffe5a738, 0 9px 18px #0319145c;
}
.dice-arena-participant .dice-arena-caption {
  min-height: 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 5px;
  border-bottom: 1px solid rgba(255, 239, 196, 0.14);
  font-size: 12px;
  position: relative;
  z-index: 1;
}
.dice-arena-participant .dice-arena-caption-name {
  min-width: 0;
  font-weight: 850;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dice-arena-participant .dice-arena-caption-result {
  flex-shrink: 0;
  font-size: 14px;
  font-weight: 850;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(8, 28, 23, 0.48);
  border: 1px solid rgba(255, 235, 191, 0.28);
}
.dice-arena-participant .dice-arena-caption-result:empty {
  display: none;
}
.dice-arena-participant.is-winner .dice-arena-caption-result {
  background: rgba(255, 224, 140, 0.24);
  border-color: rgba(255, 229, 168, 0.72);
  color: #fff6d6;
}
.dice-arena-participant .dice-arena-field {
  flex: 0 0 auto;
  width: 100%;
  min-height: 82px;
  max-width: none;
  margin: 0 auto;
  justify-content: center;
  flex-wrap: nowrap;
  gap: 8px;
  perspective: 540px;
}
.dice-arena-participant .dice-arena-slot {
  flex: 0 0 var(--tile-die-size);
  width: var(--tile-die-size);
  height: 76px;
  --arena-x: -20px;
  --arena-z: -27deg;
}
.dice-arena-participant .dice-arena-slot:nth-child(even) { --arena-x: 23px; --arena-z: 29deg; }
.dice-arena-participant .dice-arena-slot:nth-child(3) { --arena-x: -15px; --arena-z: 19deg; }
.dice-arena-participant .dice-arena-slot:nth-child(4) { --arena-x: 16px; --arena-z: -17deg; }
.dice-arena-participant .dice-arena-slot .game-die {
  --die-size: var(--tile-die-size);
  --die-half: var(--tile-die-half);
  margin: 0;
  perspective: 380px;
}
.dice-arena-participant .dice-arena-slot .game-die .game-die-face {
  border-radius: 8px;
  padding: var(--tile-face-pad);
  gap: 2px;
}
.dice-arena-participant .dice-arena-slot .game-die .game-die-pip { max-width: var(--tile-pip-size); }
.dice-arena-placement {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: center;
  position: relative;
  z-index: 1;
  min-height: 20px;
  padding: 2px 10px;
  border-radius: 999px;
  background: rgba(8, 28, 23, 0.45);
  border: 1px solid rgba(227, 216, 170, 0.22);
  color: #acc7b4;
  text-align: center;
  font-size: 11px;
  font-weight: 850;
}
.dice-arena-placement:empty {
  visibility: hidden;
}
.dice-arena-participant.is-settled .dice-arena-placement { color: #e3e8be; }
.dice-arena-participant.is-winner .dice-arena-placement {
  color: #fff3c4;
  background: rgba(255, 221, 133, 0.22);
  border-color: rgba(255, 229, 168, 0.68);
}
.dice-arena-grid--medium .dice-arena-participant { --tile-die-size: 43px; --tile-die-half: 21.5px; --tile-face-pad: 7px; --tile-pip-size: 7px; }
.dice-arena-grid--packed .dice-arena-participant { --tile-die-size: 36px; --tile-die-half: 18px; --tile-face-pad: 6px; --tile-pip-size: 6px; min-height: 138px; padding: 9px; }
.dice-arena-grid--packed .dice-arena-field { min-height: 73px; gap: 5px; }
.dice-arena-grid--packed .dice-arena-caption { font-size: 11px; }
.dice-arena-grid--packed .dice-arena-caption-result { font-size: 13px; }
.dice-arena-grid--packed .dice-arena-slot { height: 64px; }
.dice-arena-grid--solo .dice-arena-participant { min-height: 235px; --tile-die-size: 66px; --tile-die-half: 33px; --tile-face-pad: 10px; --tile-pip-size: 11px; }
.dice-arena-grid--solo .dice-arena-field { min-height: 165px; gap: 17px; }
.dice-arena-grid--solo .dice-arena-slot { height: 124px; }
.dice-arena-participant .game-die.is-rolling .game-die-motion {
  animation: dice-arena-hop 1950ms cubic-bezier(.2,.6,.24,1) both;
  animation-delay: calc(var(--arena-player-delay,0ms) + var(--piece-index) * 48ms);
}
.dice-arena-participant .game-die.is-rolling .game-die-cube {
  animation: dice-arena-tumble 1950ms cubic-bezier(.14,.56,.24,1) both;
  animation-delay: calc(var(--arena-player-delay,0ms) + var(--piece-index) * 48ms);
}
.dice-arena-participant .game-die.is-rolling::after {
  animation: dice-arena-shadow 1950ms ease both;
  animation-delay: calc(var(--arena-player-delay,0ms) + var(--piece-index) * 48ms);
}
.dice-arena-participant .game-die.is-rolling::before {
  animation: dice-arena-ring 1950ms ease both;
  animation-delay: calc(var(--arena-player-delay,0ms) + var(--piece-index) * 48ms);
}
@media (max-width: 800px) {
  .dice-arena-grid--medium, .dice-arena-grid--packed { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .dice-arena-grid--medium .dice-arena-participant { --tile-die-size: 40px; --tile-die-half: 20px; }
}
@media (max-width: 560px) {
  #diceModal .dice-roll-stage.is-dice-arena { padding: 8px; border-radius: 17px; }
  .dice-arena-grid { gap: 8px; padding: 1px; }
  .dice-arena-grid--small, .dice-arena-grid--medium, .dice-arena-grid--packed { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .dice-arena-participant, .dice-arena-grid--medium .dice-arena-participant, .dice-arena-grid--packed .dice-arena-participant {
    --tile-die-size: 32px; --tile-die-half: 16px; --tile-face-pad: 5px; --tile-pip-size: 5.5px;
    min-height: 136px; padding: 10px 8px 8px;
    border-radius: 12px;
  }
  .dice-arena-grid:not(.dice-arena-grid--solo)[data-dice-count="1"] .dice-arena-participant,
  .dice-arena-grid:not(.dice-arena-grid--solo)[data-dice-count="2"] .dice-arena-participant {
    --tile-die-size: 38px; --tile-die-half: 19px; --tile-face-pad: 6px; --tile-pip-size: 6.5px;
  }
  .dice-arena-participant .dice-arena-caption { min-height: 24px; font-size: 11px; gap: 5px; }
  .dice-arena-participant .dice-arena-caption-name { line-height: 1.3; }
  .dice-arena-participant .dice-arena-caption-result { font-size: 12px; padding: 1px 6px; }
  .dice-arena-participant .dice-arena-field { gap: 5px; min-height: 68px; }
  .dice-arena-participant .dice-arena-slot, .dice-arena-grid--packed .dice-arena-slot { height: 60px; }
  .dice-arena-participant .dice-arena-slot .game-die .game-die-face { border-radius: 6px; gap: 1.5px; }
  .dice-arena-placement { min-height: 18px; font-size: 10.5px; padding: 2px 8px; }
  .dice-arena-grid--solo .dice-arena-participant { --tile-die-size: 58px; --tile-die-half: 29px; --tile-face-pad: 9px; --tile-pip-size: 10px; min-height: 220px; }
  .dice-arena-grid--solo .dice-arena-field { min-height: 140px; gap: 13px; }
  .dice-arena-grid--solo .dice-arena-slot { height: 110px; }
}
@media (max-width: 380px) {
  .dice-arena-participant, .dice-arena-grid--medium .dice-arena-participant, .dice-arena-grid--packed .dice-arena-participant {
    --tile-die-size: 27px; --tile-die-half: 13.5px; --tile-face-pad: 4px; --tile-pip-size: 4.5px;
    padding-inline: 6px;
  }
  .dice-arena-grid:not(.dice-arena-grid--solo)[data-dice-count="1"] .dice-arena-participant,
  .dice-arena-grid:not(.dice-arena-grid--solo)[data-dice-count="2"] .dice-arena-participant {
    --tile-die-size: 34px; --tile-die-half: 17px; --tile-face-pad: 5px; --tile-pip-size: 6px;
  }
  .dice-arena-participant .dice-arena-field { gap: 4px; }
}

/* Ladder-style roster on dice only: editable name, cycling avatar, per-row
   removal and a single accessible add action. Does not alter Hwatu's UI. */
#diceModal .dice-names.dice-roster {
  display: grid;
  grid-template-columns: repeat(2,minmax(0,1fr));
  gap: 10px;
  margin-top: 12px;
}
#diceModal .dice-roster .dice-player-field {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  padding: 7px 8px;
  border: 1px solid #557476;
  border-radius: 12px;
  background: #192f38;
  transition: border-color .15s ease,background .15s ease;
}
#diceModal .dice-roster .dice-player-field:focus-within { border-color: #d5ef96; background: #203b44; }
#diceModal .dice-roster .dice-name-number {
  flex: 0 0 18px;
  min-width: 18px;
  text-align: center;
  color: #b7cda6;
  font-size: 11px;
  font-weight: 750;
}
#diceModal .dice-roster .dice-player-avatar {
  display: grid;
  place-items: center;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  border: 1px solid #658681;
  border-radius: 11px;
  background: #35545b;
  color: #fff;
  font: 25px/1 system-ui,sans-serif;
  cursor: pointer;
}
#diceModal .dice-roster .dice-player-field input {
  flex: 1;
  min-width: 0;
  width: 100%;
  min-height: 40px;
  padding: 6px 2px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #f8fff1;
  font-size: 16px;
  font-weight: 750;
  text-overflow: ellipsis;
}
#diceModal .dice-roster .dice-player-field input:focus-visible { outline: none; }
#diceModal .dice-roster .dice-player-remove {
  flex: 0 0 44px;
  width: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #d1dfd9;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
#diceModal .dice-roster .dice-player-remove:not(:disabled):hover { background: #65434b; color: #fff; }
#diceModal .dice-roster .dice-player-remove:disabled { opacity: .25; cursor: not-allowed; }
#diceModal .dice-roster :is(.dice-player-avatar,.dice-player-remove,.dice-player-add):focus-visible {
  outline: 2px solid #d5ef96;
  outline-offset: 2px;
}
#diceModal .dice-roster .dice-player-controls {
  grid-column: 1 / -1;
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 5px;
}
#diceModal .dice-roster .dice-player-add {
  min-height: 42px;
  padding: 9px 15px;
  border: 1px solid #d7f497;
  border-radius: 10px;
  background: #d7f497;
  color: #1c362d;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}
#diceModal .dice-roster .dice-player-add:disabled { opacity: .45; cursor: not-allowed; }
#diceModal .dice-roster .dice-member-count { color: #bad0c5; font-size: 12px; }
@media(max-width:600px) {
  #diceModal .dice-names.dice-roster { grid-template-columns: minmax(0,1fr); gap: 8px; }
}
@media(prefers-reduced-motion:reduce) {
  #diceModal .dice-roster .dice-player-field { transition: none; }
}

/* Lay out by the actual arena width, not only the device viewport: the same
   dice controller also runs inside a narrower homepage modal. */
#diceModal .dice-roll-stage.is-dice-arena { container: dice-arena / inline-size; }
@container dice-arena (max-width: 850px) {
  .dice-arena-grid--packed { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .dice-arena-grid--small[data-dice-count="4"] { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .dice-arena-grid:not(.dice-arena-grid--solo)[data-dice-count="1"] .dice-arena-participant,
  .dice-arena-grid:not(.dice-arena-grid--solo)[data-dice-count="2"] .dice-arena-participant {
    --tile-die-size: 42px; --tile-die-half: 21px; --tile-face-pad: 6px; --tile-pip-size: 7px;
  }
}
@container dice-arena (max-width: 650px) {
  .dice-arena-grid[data-dice-count="4"] { grid-template-columns: minmax(0,1fr); }
  .dice-arena-grid[data-dice-count="4"] .dice-arena-participant {
    --tile-die-size: 52px; --tile-die-half: 26px; --tile-face-pad: 8px; --tile-pip-size: 9px;
    min-height: 165px; padding: 11px 12px;
  }
  .dice-arena-grid[data-dice-count="4"] .dice-arena-field { min-height: 102px; gap: 8px; }
  .dice-arena-grid[data-dice-count="4"] .dice-arena-slot { height: 88px; }
}
@container dice-arena (max-width: 290px) {
  .dice-arena-grid[data-dice-count="4"] .dice-arena-participant {
    --tile-die-size: 42px; --tile-die-half: 21px; --tile-face-pad: 6px; --tile-pip-size: 7px;
  }
  .dice-arena-grid[data-dice-count="4"] .dice-arena-field { gap: 5px; }
}

/* ---- css/modules/game-pieces.css ---- */
/* Shared one-shot game-piece motion for local and online dice / hwatu. */
#party-dice.has-pieces { gap: 10px; padding: 18px 8px; perspective: none; }
#party-dice.has-pieces > span { display: inline-flex; flex: 0 0 auto; min-width: 0; width: auto; height: auto; padding: 0; border: 0; background: none; box-shadow: none; animation: none; transform: none; }
.party-result-pieces { display: flex; gap: 8px; margin-top: 6px; }

.game-die {
  --die-size: 36px;
  --die-half: 18px;
  --piece-index: 0;
  position: relative;
  display: inline-grid;
  flex: 0 0 auto;
  width: var(--die-size);
  height: var(--die-size);
  margin: 8px 0 6px;
  perspective: 300px;
  transform-style: preserve-3d;
  vertical-align: middle;
  isolation: isolate;
}
.game-die.is-large { --die-size: 56px; --die-half: 28px; margin: 15px 4px 10px; }
.game-die::before {
  content: '';
  position: absolute;
  z-index: -1;
  left: 50%;
  bottom: -10px;
  width: 110%;
  height: 14px;
  border: 2px solid #d5ef9680;
  border-radius: 50%;
  opacity: 0;
  transform: translateX(-50%) scale(.25);
  pointer-events: none;
}
.game-die::after {
  content: '';
  position: absolute;
  z-index: -2;
  inset: auto 5% -6px;
  height: 9px;
  border-radius: 50%;
  background: #0717164d;
  filter: blur(.5px);
  transform: scaleX(.9);
}
.game-die-motion, .game-die-cube {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
}
.game-die-face {
  position: absolute;
  display: grid;
  grid-template: repeat(3,1fr) / repeat(3,1fr);
  align-items: center;
  justify-items: center;
  gap: 2px;
  inset: 0;
  box-sizing: border-box;
  padding: 7px;
  border: 1px solid #faf5db;
  border-radius: 8px;
  background: linear-gradient(145deg,#fffdf0,#e2e8d3);
  box-shadow: inset 0 0 0 1px #fff8, 0 3px 0 #829181;
  backface-visibility: hidden;
}
.game-die-pip {
  display: block;
  width: 100%;
  max-width: 7px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #243f38;
  box-shadow: inset 0 1px 1px #0005;
}
/* Traditional die: the single central pip on the 1 face is red. */
.game-die-face--one .game-die-pip {
  background: radial-gradient(circle at 35% 30%, #ed6561, #b6262b 76%);
  box-shadow: inset 0 1px 2px #6f141666, 0 1px 1px #fff8;
}
.game-die.is-large .game-die-face { padding: 10px; gap: 3px; border-radius: 12px; }
.game-die.is-large .game-die-pip { max-width: 10px; }

.game-die.is-rolling .game-die-face {
  border-radius: 4px;
  box-shadow: inset 0 0 0 1px #fff8, 0 2px 0 #829181;
}
.game-die.is-rolling .game-die-face--front { transform: translateZ(var(--die-half)); }
.game-die-face--back { transform: rotateY(180deg) translateZ(var(--die-half)); }
.game-die-face--right { transform: rotateY(90deg) translateZ(var(--die-half)); background: #d9dfcd; }
.game-die-face--left { transform: rotateY(-90deg) translateZ(var(--die-half)); background: #f3f3e2; }
.game-die-face--top { transform: rotateX(90deg) translateZ(var(--die-half)); background: #fffcec; }
.game-die-face--bottom { transform: rotateX(-90deg) translateZ(var(--die-half)); background: #c6d0ba; }

.game-die.is-rolling .game-die-motion {
  will-change: transform;
  animation: game-die-throw 1040ms cubic-bezier(.16,.72,.22,1) both;
  animation-delay: calc(var(--piece-index) * 38ms);
}
.game-die.is-rolling .game-die-cube {
  will-change: transform;
  animation: game-die-tumble 1040ms cubic-bezier(.12,.72,.24,1) both;
  animation-delay: calc(var(--piece-index) * 38ms);
}
.game-die.is-rolling::after {
  animation: game-die-shadow 1040ms ease-out both;
  animation-delay: calc(var(--piece-index) * 38ms);
}
.game-die.is-rolling::before {
  animation: game-die-impact-ring 1040ms ease-out both;
  animation-delay: calc(var(--piece-index) * 38ms);
}

.game-die.is-landed .game-die-motion {
  will-change: transform;
  animation: game-die-land 560ms cubic-bezier(.18,.78,.25,1.25) both;
  animation-delay: calc(var(--piece-index) * 45ms);
}
.game-die.is-landed::after {
  animation: game-die-land-shadow 560ms ease-out both;
  animation-delay: calc(var(--piece-index) * 45ms);
}
.game-die.is-landed::before {
  animation: game-die-result-ring 560ms ease-out both;
  animation-delay: calc(var(--piece-index) * 45ms);
}

@keyframes game-die-throw {
  0%   { transform: translate(26px,14px) scale(.72); }
  16%  { transform: translate(-18px,-42px) scale(1.04); }
  37%  { transform: translate(12px,-9px) scale(1.03); }
  51%  { transform: translate(-8px,1px) scale(1.10,.88); }
  66%  { transform: translate(7px,-17px) scale(.98); }
  79%  { transform: translate(-3px,0) scale(1.06,.93); }
  90%  { transform: translate(2px,-5px) scale(.99); }
  100% { transform: none; }
}
@keyframes game-die-tumble {
  0%   { transform: rotateX(760deg) rotateY(-610deg) rotateZ(var(--die-spin-start,-95deg)); }
  32%  { transform: rotateX(470deg) rotateY(-390deg) rotateZ(var(--die-spin-mid,48deg)); }
  58%  { transform: rotateX(205deg) rotateY(-170deg) rotateZ(var(--die-spin-late,-26deg)); }
  78%  { transform: rotateX(54deg) rotateY(-42deg) rotateZ(12deg); }
  91%  { transform: rotateX(-12deg) rotateY(9deg) rotateZ(-4deg); }
  100% { transform: rotateX(0) rotateY(0) rotateZ(0); }
}
@keyframes game-die-shadow {
  0%   { transform: scale(.42); opacity: .18; filter: blur(4px); }
  16%  { transform: scale(.28); opacity: .13; filter: blur(5px); }
  51%  { transform: scaleX(1.08); opacity: .8; filter: blur(.5px); }
  66%  { transform: scale(.58); opacity: .32; filter: blur(3px); }
  79%  { transform: scaleX(.98); opacity: .72; filter: blur(1px); }
  100% { transform: scaleX(.9); opacity: 1; filter: blur(.5px); }
}
@keyframes game-die-impact-ring {
  0%,45% { opacity: 0; transform: translateX(-50%) scale(.2); }
  52% { opacity: .72; transform: translateX(-50%) scale(.65); }
  64% { opacity: 0; transform: translateX(-50%) scale(1.3); }
  76% { opacity: .45; transform: translateX(-50%) scale(.55); }
  90%,100% { opacity: 0; transform: translateX(-50%) scale(1.15); }
}
@keyframes game-die-land {
  0%   { transform: translateY(-16px) rotate(var(--die-land-start,-10deg)) scale(.9); }
  42%  { transform: translateY(2px) rotate(var(--die-land-hit,5deg)) scale(1.08,.91); }
  67%  { transform: translateY(-5px) rotate(var(--die-land-bounce,-2deg)) scale(.99); }
  83%  { transform: translateY(1px) rotate(1deg) scale(1.02,.98); }
  100% { transform: none; }
}
@keyframes game-die-land-shadow {
  0% { transform: scale(.55); opacity: .35; }
  42% { transform: scaleX(1.08); opacity: .95; }
  67% { transform: scale(.78); opacity: .55; }
  100% { transform: scaleX(.9); opacity: 1; }
}
@keyframes game-die-result-ring {
  0%,30% { opacity: 0; transform: translateX(-50%) scale(.25); }
  43% { opacity: .75; transform: translateX(-50%) scale(.6); }
  100% { opacity: 0; transform: translateX(-50%) scale(1.45); }
}

.game-card {
  --piece-index: 0;
  --card-width: 60px;
  position: relative;
  display: inline-block;
  flex: 0 0 auto;
  width: var(--card-width);
  height: calc(var(--card-width) * 47 / 30);
  margin: 3px 1px 5px;
  border-radius: calc(var(--card-width) / 12);
  perspective: 520px;
  vertical-align: middle;
  isolation: isolate;
}
.game-card.is-compact { --card-width: 42px; }
.game-card::after {
  content: '';
  position: absolute;
  z-index: 2;
  inset: -5% -18%;
  border-radius: 50%;
  background: linear-gradient(110deg,transparent 35%,#fff9 48%,transparent 60%);
  opacity: 0;
  transform: translateX(-55%) rotate(8deg);
  pointer-events: none;
}
.game-card-turn {
  position: absolute;
  inset: 0;
  display: block;
  border-radius: inherit;
  transform-style: preserve-3d;
  box-shadow: 0 3px 0 #582b27, 0 5px 8px #06171955;
}
.game-card-front, .game-card-back {
  position: absolute;
  inset: 0;
  display: block;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  border: calc(var(--card-width) / 20) solid #ba1420;
  border-radius: inherit;
  background-origin: padding-box;
  background-clip: padding-box;
  background-repeat: no-repeat;
  backface-visibility: hidden;
}
.game-card-front { background-color: #ba1420; }
.game-card-front.has-face { background-image: url('../assets/cards/hwatu-sheet.webp'); }
.game-card-back {
  transform: rotateY(180deg);
  background: #bd111b url('../assets/cards/hwatu-back.jpg') center / cover no-repeat;
  background-origin: padding-box;
  background-clip: padding-box;
}
.game-card.is-hidden .game-card-turn { transform: rotateY(180deg); }

.game-card.is-dealing {
  will-change: transform;
  animation: game-card-flight 990ms cubic-bezier(.18,.72,.24,1) both;
  animation-delay: calc(var(--piece-index) * 55ms);
}
.game-card.is-dealing .game-card-turn {
  will-change: transform;
  animation: game-card-reveal 990ms cubic-bezier(.18,.72,.24,1) both;
  animation-delay: calc(var(--piece-index) * 55ms);
}
.game-card.is-dealing.is-hidden .game-card-turn { animation-name: game-card-deal; }

.game-card.is-revealed {
  will-change: transform;
  animation: game-card-table-slap 760ms cubic-bezier(.16,.78,.24,1.18) both;
  animation-delay: calc(var(--piece-index) * 70ms);
}
.game-card.is-revealed .game-card-turn {
  will-change: transform;
  animation: game-card-turnover 760ms cubic-bezier(.2,.72,.2,1) both;
  animation-delay: calc(var(--piece-index) * 70ms);
}
.game-card.is-revealed::after {
  animation: game-card-shine 760ms ease-out both;
  animation-delay: calc(var(--piece-index) * 70ms);
}

@keyframes game-card-flight {
  0%   { transform: translate(38px,-36px) rotateZ(22deg) scale(.72); opacity: 0; }
  18%  { opacity: 1; }
  42%  { transform: translate(-8px,4px) rotateZ(-9deg) scale(1.03); }
  61%  { transform: translate(5px,-8px) rotateZ(5deg) scale(.99); }
  78%  { transform: translate(-2px,1px) rotateZ(-2deg); }
  100% { transform: none; opacity: 1; }
}
@keyframes game-card-reveal {
  0%,34% { transform: rotateY(180deg); }
  56% { transform: rotateY(92deg) rotateZ(-4deg) scale(1.05); }
  77% { transform: rotateY(-14deg) rotateZ(2deg); }
  90% { transform: rotateY(5deg) rotateZ(-1deg); }
  100% { transform: none; }
}
@keyframes game-card-deal {
  0% { transform: rotateY(180deg); }
  100% { transform: rotateY(180deg); }
}
@keyframes game-card-table-slap {
  0%   { transform: translate(24px,-30px) rotateZ(var(--card-spin-start,16deg)) scale(.78); opacity: 0; }
  30%  { transform: translate(-5px,2px) rotateZ(var(--card-spin-hit,-7deg)) scale(1.06); opacity: 1; }
  52%  { transform: translate(3px,-5px) rotateZ(var(--card-spin-bounce,3deg)) scale(.99); }
  72%  { transform: translate(-1px,1px) rotateZ(var(--card-spin-settle,-1deg)) scale(1.015); }
  100% { transform: none; opacity: 1; }
}
@keyframes game-card-turnover {
  0%   { transform: rotateY(180deg) rotateX(8deg); }
  36%  { transform: rotateY(108deg) rotateX(-5deg) scale(1.05); }
  58%  { transform: rotateY(34deg) rotateX(2deg); }
  76%  { transform: rotateY(-10deg); }
  90%  { transform: rotateY(4deg); }
  100% { transform: none; }
}
@keyframes game-card-shine {
  0%,48% { opacity: 0; transform: translateX(-55%) rotate(8deg); }
  58% { opacity: .58; }
  78% { opacity: 0; transform: translateX(58%) rotate(8deg); }
  100% { opacity: 0; transform: translateX(58%) rotate(8deg); }
}

@media (max-width: 420px) {
  .game-die { --die-size: 32px; --die-half: 16px; }
  .game-die-face { padding: 6px; border-radius: 7px; }
  .game-die.is-large { --die-size: 48px; --die-half: 24px; margin-left: 1px; margin-right: 1px; }
  .game-card.is-revealed { animation-duration: 680ms; }
  .game-card.is-revealed .game-card-turn,
  .game-card.is-revealed::after { animation-duration: 680ms; }
}

@media (prefers-reduced-motion: reduce) {
  .game-die.is-rolling .game-die-motion,
  .game-die.is-rolling .game-die-cube,
  .game-die.is-rolling::before,
  .game-die.is-rolling::after,
  .game-die.is-landed .game-die-motion,
  .game-die.is-landed::before,
  .game-die.is-landed::after,
  .game-card.is-dealing,
  .game-card.is-dealing .game-card-turn,
  .game-card.is-revealed,
  .game-card.is-revealed .game-card-turn,
  .game-card.is-revealed::after {
    animation: none;
  }
}

/* Hwatu-style shuffle: one thick stack jitters, twists and snaps square. */
.game-card-shuffle {
  position: relative;
  display: inline-block;
  width: 112px;
  height: 88px;
  flex: 0 0 112px;
  perspective: 520px;
  isolation: isolate;
}
.game-card-shuffle::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: 10px;
  width: 54px;
  height: 13px;
  border-radius: 50%;
  background: #07171655;
  filter: blur(2px);
  transform: translateX(-50%) scaleX(.86);
  animation: game-card-shuffle-shadow 1040ms ease-out both;
  pointer-events: none;
}
.game-card-shuffle-deck {
  position: absolute;
  inset: 0;
  display: block;
  transform-style: preserve-3d;
  animation: game-card-shuffle-stack 1040ms cubic-bezier(.16,.78,.23,1) both;
}
.game-card-shuffle-card {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 42px;
  height: 66px;
  margin: -36px 0 0 -21px;
  border: 2px solid #ba1420;
  border-radius: 5px;
  background: #bd111b url('../assets/cards/hwatu-back.jpg') center / cover no-repeat;
  box-shadow: 0 1px 0 #7c0a11, 0 2px 0 #5a0c10;
  backface-visibility: hidden;
}
.game-card-shuffle-card--layer {
  z-index: calc(20 - var(--shuffle-index));
  transform: translate3d(var(--stack-x,0),var(--stack-y,0),calc(var(--shuffle-index) * -0.45px)) rotateZ(var(--stack-rot,0));
}

@keyframes game-card-shuffle-stack {
  0%   { transform: translate3d(0,0,0) rotateX(0) rotateY(0) rotateZ(0) scale(1); }
  8%   { transform: translate3d(-5px,-2px,0) rotateX(3deg) rotateY(8deg) rotateZ(-4.5deg) scale(1.01); }
  16%  { transform: translate3d(6px,1px,0) rotateX(-2deg) rotateY(-8deg) rotateZ(4deg) scale(.995); }
  25%  { transform: translate3d(-4px,2px,0) rotateX(4deg) rotateY(5deg) rotateZ(-3deg) scale(1.008); }
  34%  { transform: translate3d(5px,-1px,0) rotateX(-3deg) rotateY(-6deg) rotateZ(3.4deg) scale(.997); }
  44%  { transform: translate3d(-3px,0,0) rotateX(2deg) rotateY(4deg) rotateZ(-2.4deg) scale(1.005); }
  54%  { transform: translate3d(4px,1px,0) rotateX(-2deg) rotateY(-4deg) rotateZ(2.3deg) scale(.998); }
  65%  { transform: translate3d(-2px,-1px,0) rotateX(1deg) rotateY(3deg) rotateZ(-1.4deg) scale(1.003); }
  76%  { transform: translate3d(2px,0,0) rotateX(-1deg) rotateY(-2deg) rotateZ(1deg) scale(1); }
  86%  { transform: translate3d(0,-1px,0) rotateX(0) rotateY(0) rotateZ(-.4deg) scale(1); }
  93%  { transform: translate3d(0,2px,0) rotateX(0) rotateY(0) rotateZ(0) scale(1.035,.965); }
  100% { transform: translate3d(0,0,0) rotateX(0) rotateY(0) rotateZ(0) scale(1); }
}
@keyframes game-card-shuffle-shadow {
  0%   { opacity: .72; transform: translateX(-50%) scaleX(.86); }
  8%   { opacity: .48; transform: translateX(-50%) scaleX(.72); }
  16%  { opacity: .78; transform: translateX(-50%) scaleX(.92); }
  25%  { opacity: .52; transform: translateX(-50%) scaleX(.76); }
  34%  { opacity: .8; transform: translateX(-50%) scaleX(.94); }
  54%  { opacity: .6; transform: translateX(-50%) scaleX(.8); }
  76%  { opacity: .75; transform: translateX(-50%) scaleX(.88); }
  93%  { opacity: .95; transform: translateX(-50%) scaleX(1.05); }
  100% { opacity: .72; transform: translateX(-50%) scaleX(.86); }
}

@media (max-width: 420px) {
  .game-card-shuffle { width: 104px; height: 84px; flex-basis: 104px; }
  .game-card-shuffle-card { width: 38px; height: 60px; margin: -33px 0 0 -19px; }
}

@media (prefers-reduced-motion: reduce) {
  .game-card-shuffle-deck,
  .game-card-shuffle::after {
    animation: none;
  }
}

/* ---- css/style.css root rules ---- */
/* Cross-Browser Normalization */
/* This section ensures consistent rendering between iOS and Android */

/* Reset appearance for inputs and buttons across all browsers */
input, button, select, textarea {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  border-radius: 0;
  font-family: inherit;
}

/* Ensure smooth scrolling on all browsers */
* {
  -webkit-overflow-scrolling: touch;
  -ms-overflow-style: -ms-autohiding-scrollbar;
  scrollbar-width: thin;
}

/* Hide scrollbars from most elements but maintain touch functionality */
* {
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}

/* Hide WebKit scrollbars except for race-results and results-list */
*:not(.race-results):not(.results-list)::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

/* Only hide scrollbars visually for race-results and results-list but maintain functionality */
.race-results, .results-list {
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE and Edge */
}

.race-results::-webkit-scrollbar, .results-list::-webkit-scrollbar {
  width: 0;
  display: none;
}

/* Font rendering consistency */
html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Ensure consistent flex behavior */
.flex-container {
  display: -webkit-box;
  display: -webkit-flex;
  display: -ms-flexbox;
  display: flex;
}

/* Consistent button styling across browsers */
button {
  background-color: transparent;
  cursor: pointer;
  border: none;
}

/* Ensure consistent animation performance */
.animated {
  -webkit-animation-duration: 1s;
  animation-duration: 1s;
  -webkit-animation-fill-mode: both;
  animation-fill-mode: both;
}

/* Prevent text size adjustment after orientation changes */
html {
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
}

/* Fix input and button styling in iOS */
input[type="button"], input[type="submit"], input[type="reset"], 
button, .btn, .button {
  -webkit-appearance: none;
  border-radius: 0;
}

/* Promote only moving race sprites, rather than every static UI element. */
.race-active .horse-motion {
  will-change: transform;
}

/* Lightning effect CSS */
.lightning-effect {
  width: 80px;
  height: 120px;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 80 120"><path d="M32,0 L20,45 L45,45 L10,120 L25,55 L0,55 L32,0" fill="%23FFD700"/></svg>');
  background-size: contain;
  background-repeat: no-repeat;
  filter: drop-shadow(0 0 15px rgba(255, 215, 0, 0.9));
  z-index: 90;
  will-change: opacity, transform;
}

/* Simplified lightning effect for low performance mode */
.lightning-effect-simple {
  filter: none;
  animation: lightning-flash-simple 0.5s ease-out !important;
}

/* Boost effect CSS */
.boost-effect {
  width: 60px;
  height: 20px;
  background: linear-gradient(to left, rgba(255, 165, 0, 0), rgba(255, 165, 0, 0.8), rgba(255, 0, 0, 0.8));
  border-radius: 5px;
  filter: blur(2px);
  z-index: 99;
  will-change: opacity, transform;
  transform-origin: right center;
  animation: boost-anim 0.8s ease-out forwards;
}

/* Simplified boost effect for low performance mode */
.boost-effect-simple {
  width: 40px;
  height: 15px;
  background: linear-gradient(to left, rgba(255, 165, 0, 0), rgba(255, 165, 0, 0.7));
  filter: none;
  animation: boost-anim-simple 0.6s ease-out forwards !important;
}

