:root {
  --bowling-overlay-z: 260000;
  --bowling-text: #fff3e1;
  --bowling-text-dark: #5a3116;
  --bowling-accent: #ffc35c;
  --bowling-accent-strong: #ff9e2c;
  --bowling-accent-green: #63d33d;
  --bowling-panel: rgba(57, 28, 10, 0.82);
  --bowling-panel-soft: rgba(255, 248, 236, 0.1);
  --bowling-border: rgba(255, 214, 145, 0.28);
  --bowling-shadow: 0 24px 80px rgba(0, 0, 0, 0.46);
}

#bowlingOverlay {
  position: fixed;
  inset: 0;
  z-index: var(--bowling-overlay-z);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  direction: rtl;
  transition: opacity 240ms ease, visibility 240ms ease;
}

#bowlingOverlay.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.bowling-backdrop {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 18%, rgba(255, 228, 188, 0.16), transparent 28%),
    radial-gradient(circle at 78% 14%, rgba(255, 185, 95, 0.12), transparent 24%),
    linear-gradient(180deg, rgba(12, 7, 4, 0.78), rgba(8, 5, 3, 0.92));
  backdrop-filter: blur(9px);
}

.bowling-screen {
  position: relative;
  width: min(1300px, 96vw);
  opacity: 0;
  transform: translateY(18px) scale(0.985);
  transition: opacity 260ms ease, transform 320ms ease;
  pointer-events: none;
}

.bowling-screen.is-active {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.bowling-frame-shell {
  position: relative;
  width: 100%;
  aspect-ratio: 1395 / 913;
  filter: drop-shadow(var(--bowling-shadow));
}

.bowling-frame-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}

.bowling-close-btn {
  position: absolute;
  top: 2.25%;
  right: 2.2%;
  width: 5.6%;
  height: 8.8%;
  min-width: 42px;
  min-height: 42px;
  border: none;
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  z-index: 6;
}

.bowling-close-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

.bowling-selection-content,
.bowling-game-layout {
  position: absolute;
  left: 4.3%;
  top: 15.3%;
  width: 91.2%;
  height: 75%;
  z-index: 4;
}

.bowling-selection-content {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
}

.bowling-selection-topbar {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60px;
}

.bowling-selection-title {
  margin: 0;
  font: 900 clamp(28px, 3vw, 44px) / 1.1 "Cairo", system-ui, sans-serif;
  color: var(--bowling-text-dark);
  text-shadow: 0 2px 0 rgba(255, 231, 198, 0.42);
  letter-spacing: 0.02em;
}

.bowling-mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: stretch;
  min-height: 0;
  direction: ltr;
}

.bowling-mode-card {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 14px 18px;
  border-radius: 34px;
  border: 2px solid rgba(129, 73, 24, 0.3);
  background:
    linear-gradient(180deg, rgba(255, 248, 233, 0.72), rgba(245, 223, 190, 0.8));
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.72),
    0 12px 28px rgba(94,51,14,0.16);
  text-align: center;
  backdrop-filter: blur(2px);
}

.bowling-mode-card.is-disabled {
  filter: grayscale(0.22) saturate(0.82);
  opacity: 0.88;
}

.bowling-mode-badge {
  align-self: center;
  min-width: 220px;
  padding: 10px 26px 12px;
  border-radius: 22px;
  border: 2px solid rgba(255, 194, 94, 0.45);
  background: linear-gradient(180deg, #6f3a14, #4c2410);
  color: #fff5de;
  font: 900 clamp(20px, 2.1vw, 34px) / 1.05 "Cairo", system-ui, sans-serif;
  box-shadow: 0 10px 22px rgba(75, 36, 16, 0.22);
}

.bowling-mode-preview {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  border-radius: 28px;
  border: 2px solid rgba(189, 130, 53, 0.65);
  background:
    linear-gradient(180deg, rgba(7, 17, 32, 0.16), rgba(17, 8, 3, 0.18)),
    url("../assets/bowling/lane.png") center center / cover no-repeat;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.18),
    0 12px 22px rgba(55, 24, 7, 0.22);
}

.bowling-mode-card--solo .bowling-mode-preview {
  cursor: pointer;
}

.bowling-mode-preview::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(255, 217, 156, 0.05), rgba(255, 163, 58, 0.16)),
    radial-gradient(circle at 50% 4%, rgba(255, 238, 210, 0.26), transparent 44%);
}

.bowling-mode-preview--solo .bowling-preview-ball {
  position: absolute;
  right: 17%;
  bottom: 12%;
  width: 21%;
  z-index: 2;
  filter: drop-shadow(0 18px 18px rgba(0, 0, 0, 0.28));
  transform: rotate(-12deg);
}

.bowling-mode-preview--solo .bowling-preview-pin {
  position: absolute;
  top: 14%;
  width: 11%;
  z-index: 2;
  filter: drop-shadow(0 10px 10px rgba(0, 0, 0, 0.22));
}

.bowling-mode-preview--solo .bowling-preview-pin.pin-a { left: 38%; }
.bowling-mode-preview--solo .bowling-preview-pin.pin-b { left: 47%; top: 17%; }
.bowling-mode-preview--solo .bowling-preview-pin.pin-c { left: 56%; top: 14.5%; }

.bowling-mode-preview--solo .bowling-preview-avatar {
  position: absolute;
  left: 19%;
  bottom: 13%;
  width: 22%;
  aspect-ratio: 0.55;
  z-index: 2;
}

.bowling-mode-preview--solo .bowling-preview-avatar::before,
.bowling-mode-preview--solo .bowling-preview-avatar::after {
  content: "";
  position: absolute;
  border-radius: 999px;
  background: linear-gradient(180deg, #2a3648, #121820);
}

.bowling-mode-preview--solo .bowling-preview-avatar::before {
  left: 28%;
  top: 0;
  width: 44%;
  height: 20%;
  border-radius: 50%;
}

.bowling-mode-preview--solo .bowling-preview-avatar::after {
  left: 14%;
  top: 17%;
  width: 72%;
  height: 70%;
  clip-path: polygon(30% 0, 70% 0, 100% 18%, 84% 100%, 58% 100%, 53% 68%, 47% 68%, 42% 100%, 15% 100%, 0 18%);
}

.bowling-mode-preview--multi {
  filter: grayscale(0.15) saturate(0.75);
}

.bowling-mode-preview--multi::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.08), rgba(0, 0, 0, 0.18)),
    radial-gradient(circle at 18% 78%, rgba(255, 214, 138, 0.18), transparent 25%),
    radial-gradient(circle at 72% 76%, rgba(255, 214, 138, 0.14), transparent 22%);
  z-index: 1;
}

.bowling-preview-silhouettes {
  position: absolute;
  inset: auto 10% 8% 10%;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 6%;
  z-index: 2;
}

.bowling-preview-player {
  position: relative;
  width: 18%;
  aspect-ratio: 0.54;
}

.bowling-preview-player::before,
.bowling-preview-player::after {
  content: "";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(54, 42, 36, 0.94), rgba(29, 20, 18, 0.98));
}

.bowling-preview-player::before {
  top: 0;
  width: 46%;
  height: 22%;
}

.bowling-preview-player::after {
  top: 18%;
  width: 72%;
  height: 70%;
  clip-path: polygon(28% 0, 72% 0, 100% 24%, 82% 100%, 60% 100%, 54% 70%, 46% 70%, 40% 100%, 18% 100%, 0 24%);
}

.bowling-preview-lock {
  position: absolute;
  left: 50%;
  bottom: 12%;
  transform: translateX(-50%);
  min-width: 210px;
  padding: 14px 26px;
  border-radius: 22px;
  border: 2px solid rgba(255, 255, 255, 0.14);
  background: linear-gradient(180deg, rgba(103, 103, 103, 0.94), rgba(58, 58, 58, 0.96));
  color: rgba(255, 255, 255, 0.84);
  font: 900 clamp(20px, 1.8vw, 30px) / 1.1 "Cairo", system-ui, sans-serif;
  z-index: 3;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.24);
}

.bowling-mode-description {
  min-height: 42px;
  padding: 0 12px;
  color: #7a5331;
  font: 800 clamp(13px, 1vw, 16px) / 1.55 "Cairo", system-ui, sans-serif;
}

.bowling-mode-cta {
  display: none;
}

.bowling-mode-card--solo {
  cursor: pointer;
}

.bowling-mode-card--solo:hover .bowling-mode-cta {
  transform: translateY(-2px);
  box-shadow: 0 18px 30px rgba(69, 153, 22, 0.26);
  filter: brightness(1.04);
}

.bowling-selection-footer {
  align-self: center;
  width: min(640px, 82%);
  padding: 10px 18px;
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(92, 43, 13, 0.96), rgba(57, 23, 8, 0.98));
  color: #ffe8c7;
  text-align: center;
  font: 800 clamp(14px, 1.02vw, 17px) / 1.45 "Cairo", system-ui, sans-serif;
  box-shadow: 0 10px 28px rgba(61, 24, 7, 0.18);
}

.bowling-game-layout {
  display: grid;
  grid-template-columns: 1.55fr 0.88fr;
  gap: 22px;
}

.bowling-stage-shell,
.bowling-controls-shell {
  border-radius: 30px;
  border: 1px solid var(--bowling-border);
  background:
    linear-gradient(180deg, rgba(43, 22, 10, 0.82), rgba(28, 15, 8, 0.9)),
    var(--bowling-panel);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 14px 34px rgba(0, 0, 0, 0.28);
  overflow: hidden;
}

.bowling-stage-shell {
  position: relative;
  padding: 18px;
}

.bowling-stage-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.bowling-stage-title {
  color: var(--bowling-text);
  font: 900 clamp(22px, 1.8vw, 30px) / 1.05 "Cairo", system-ui, sans-serif;
}

.bowling-stage-badge {
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255, 224, 177, 0.12);
  color: #ffdca7;
  font: 800 14px / 1 "Cairo", system-ui, sans-serif;
  border: 1px solid rgba(255, 211, 154, 0.15);
}

.bowling-canvas-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1264 / 842;
  overflow: hidden;
  border-radius: 26px;
  background: #1e140f;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 12px 28px rgba(0, 0, 0, 0.28);
}

#bowlingCanvas {
  width: 100%;
  height: 100%;
  display: block;
  background: #130d09;
}

.bowling-stage-chrome {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0) 14%),
    radial-gradient(circle at 50% 0, rgba(255, 247, 218, 0.14), transparent 30%),
    linear-gradient(180deg, rgba(13, 8, 5, 0), rgba(13, 8, 5, 0.24));
}

.bowling-intro-overlay,
.bowling-result-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 28px;
  pointer-events: none;
  transition: opacity 220ms ease, visibility 220ms ease, transform 260ms ease;
}

.bowling-intro-overlay.is-hidden,
.bowling-result-overlay.is-hidden {
  opacity: 0;
  visibility: hidden;
  transform: scale(0.98);
}

.bowling-intro-overlay {
  background:
    radial-gradient(circle at center, rgba(16, 11, 7, 0.22), rgba(12, 7, 4, 0.58)),
    linear-gradient(180deg, rgba(21, 14, 9, 0.12), rgba(9, 5, 3, 0.74));
}

.bowling-intro-card,
.bowling-result-card {
  width: min(500px, 92%);
  padding: 28px 26px;
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(45, 24, 12, 0.86), rgba(24, 13, 7, 0.92)),
    rgba(33, 18, 10, 0.9);
  border: 1px solid rgba(255, 214, 151, 0.18);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.34);
  pointer-events: auto;
}

.bowling-intro-title,
.bowling-result-title {
  margin: 0 0 12px;
  color: #fff1d6;
  font: 900 clamp(28px, 2.3vw, 42px) / 1.08 "Cairo", system-ui, sans-serif;
}

.bowling-intro-text,
.bowling-result-text {
  margin: 0;
  color: rgba(255, 237, 208, 0.82);
  font: 700 clamp(15px, 1.16vw, 19px) / 1.8 "Cairo", system-ui, sans-serif;
}

.bowling-prepare-btn,
.bowling-action-btn,
.bowling-secondary-btn {
  border: none;
  border-radius: 18px;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease, filter 180ms ease, opacity 180ms ease;
  font-family: "Cairo", system-ui, sans-serif;
}

.bowling-prepare-btn,
.bowling-action-btn {
  min-width: 180px;
  padding: 14px 24px;
  background: linear-gradient(180deg, #f4c865, #d98727);
  color: #4b250e;
  font-size: clamp(18px, 1.35vw, 24px);
  font-weight: 900;
  box-shadow: 0 12px 28px rgba(221, 139, 40, 0.28);
}

.bowling-secondary-btn {
  min-width: 160px;
  padding: 13px 22px;
  background: linear-gradient(180deg, rgba(255, 245, 223, 0.16), rgba(255, 245, 223, 0.08));
  color: #f5e7cc;
  border: 1px solid rgba(255, 217, 160, 0.18);
  font-size: clamp(16px, 1.1vw, 20px);
  font-weight: 800;
}

.bowling-prepare-btn:hover,
.bowling-action-btn:hover,
.bowling-secondary-btn:hover {
  transform: translateY(-2px);
  filter: brightness(1.04);
}

.bowling-intro-actions,
.bowling-result-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 22px;
}

.bowling-controls-shell {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px 14px 20px 18px;
  overflow-y: auto;
  min-height: 0;
  scrollbar-gutter: stable;
}

.bowling-controls-title {
  color: #fff1d6;
  font: 900 clamp(22px, 1.6vw, 28px) / 1.05 "Cairo", system-ui, sans-serif;
}

.bowling-controls-copy {
  color: rgba(255, 233, 198, 0.72);
  font: 700 13px / 1.6 "Cairo", system-ui, sans-serif;
}

.bowling-control-list {
  display: grid;
  gap: 14px;
}

.bowling-control-row {
  padding: 14px 14px 12px;
  border-radius: 20px;
  background: var(--bowling-panel-soft);
  border: 1px solid rgba(255, 221, 171, 0.12);
}

.bowling-control-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.bowling-control-label {
  color: #ffeccc;
  font: 800 14px / 1.1 "Cairo", system-ui, sans-serif;
}

.bowling-control-value {
  color: var(--bowling-accent);
  font: 900 16px / 1 "Cairo", system-ui, sans-serif;
}

.bowling-control-range {
  width: 100%;
  appearance: none;
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(255, 246, 226, 0.14), rgba(255, 205, 124, 0.34));
  outline: none;
}

.bowling-control-range::-webkit-slider-thumb {
  appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid rgba(255, 240, 214, 0.86);
  background: linear-gradient(180deg, #ffcd68, #f2952f);
  box-shadow: 0 8px 16px rgba(227, 143, 42, 0.26);
  cursor: pointer;
}

.bowling-control-range::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid rgba(255, 240, 214, 0.86);
  background: linear-gradient(180deg, #ffcd68, #f2952f);
  box-shadow: 0 8px 16px rgba(227, 143, 42, 0.26);
  cursor: pointer;
}

.bowling-status-card {
  border-radius: 22px;
  padding: 16px;
  background:
    linear-gradient(180deg, rgba(255, 244, 228, 0.1), rgba(255, 244, 228, 0.04)),
    rgba(255, 244, 228, 0.06);
  border: 1px solid rgba(255, 214, 145, 0.16);
}

.bowling-release-card {
  border-radius: 22px;
  padding: 16px;
  background:
    linear-gradient(180deg, rgba(255, 244, 228, 0.1), rgba(255, 244, 228, 0.04)),
    rgba(255, 244, 228, 0.06);
  border: 1px solid rgba(255, 214, 145, 0.16);
}

.bowling-release-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.bowling-release-readout {
  color: var(--bowling-accent);
  font: 900 15px / 1 "Cairo", system-ui, sans-serif;
}

.bowling-release-meter {
  position: relative;
  height: 16px;
  margin-top: 12px;
  border-radius: 999px;
  overflow: hidden;
  background: linear-gradient(90deg, rgba(255, 246, 226, 0.1), rgba(255, 205, 124, 0.24));
  border: 1px solid rgba(255, 214, 145, 0.14);
}

.bowling-release-zone {
  position: absolute;
  top: 2px;
  bottom: 2px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 219, 117, 0.9), rgba(214, 134, 37, 0.95));
  box-shadow: 0 0 14px rgba(255, 198, 84, 0.34);
}

.bowling-release-marker {
  position: absolute;
  top: -3px;
  width: 16px;
  height: 20px;
  border-radius: 999px;
  background: linear-gradient(180deg, #fff4da, #ffbf62);
  border: 1px solid rgba(102, 52, 9, 0.34);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.22);
  transform: translateX(-50%);
}

.bowling-release-copy {
  margin-top: 10px;
  color: rgba(255, 235, 206, 0.72);
  font: 700 12px / 1.6 "Cairo", system-ui, sans-serif;
}

.bowling-status-title {
  color: #ffeccc;
  font: 900 18px / 1.1 "Cairo", system-ui, sans-serif;
}

.bowling-status-text {
  margin-top: 8px;
  color: rgba(255, 235, 206, 0.74);
  font: 700 14px / 1.8 "Cairo", system-ui, sans-serif;
  min-height: 52px;
}

.bowling-legend {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.bowling-legend-chip {
  padding: 10px 12px;
  border-radius: 16px;
  background: rgba(255, 245, 228, 0.08);
  border: 1px solid rgba(255, 214, 145, 0.12);
  color: rgba(255, 236, 206, 0.8);
  font: 800 13px / 1.4 "Cairo", system-ui, sans-serif;
}

.bowling-controls-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: auto;
  position: sticky;
  bottom: 0;
  padding-top: 12px;
  background: linear-gradient(180deg, rgba(34, 18, 9, 0), rgba(34, 18, 9, 0.9) 28%, rgba(34, 18, 9, 0.98));
}

.bowling-controls-shell::-webkit-scrollbar {
  width: 10px;
}

.bowling-controls-shell::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(255, 201, 116, 0.34);
}

.bowling-controls-shell::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.04);
}

.bowling-action-btn[disabled],
.bowling-prepare-btn[disabled],
.bowling-secondary-btn[disabled] {
  opacity: 0.58;
  cursor: not-allowed;
  transform: none !important;
  filter: none !important;
}

.bowling-result-card.is-strike {
  background:
    radial-gradient(circle at top, rgba(255, 214, 115, 0.18), transparent 40%),
    linear-gradient(180deg, rgba(55, 29, 12, 0.88), rgba(26, 14, 7, 0.94));
  border-color: rgba(255, 222, 162, 0.28);
}

.bowling-result-card.is-strike .bowling-result-title {
  color: #ffdf8b;
}

.bowling-interactable-cursor {
  cursor: var(--bowling-cursor, pointer) !important;
}

@media (max-width: 1100px) {
  .bowling-screen {
    width: min(1320px, 98vw);
  }

  .bowling-selection-content,
  .bowling-game-layout {
    left: 4.1%;
    width: 91.5%;
  }

  .bowling-game-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
  }

  .bowling-controls-shell {
    min-height: 0;
  }

  .bowling-status-text {
    min-height: 0;
  }
}

@media (max-width: 780px) {
  .bowling-screen {
    width: min(1380px, 100vw);
  }

  .bowling-selection-content,
  .bowling-game-layout {
    left: 3.6%;
    top: 13.6%;
    width: 92.8%;
    height: 77%;
  }

  .bowling-mode-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .bowling-mode-card {
    padding: 14px 14px 18px;
    border-radius: 24px;
  }

  .bowling-mode-preview {
    min-height: 170px;
  }

  .bowling-selection-footer {
    padding: 12px 16px;
  }

  .bowling-legend {
    grid-template-columns: 1fr;
  }
}
