/* ========= Root Variables ========= */
:root {
  --layout-width: min(90vw, 420px);
  --main-width: var(--layout-width);
  --max-board: var(--layout-width);
  --content-width: calc(var(--layout-width) * 0.85);
  --timer-block-height: clamp(48px, 8vh, 90px);
  --timer-block-width: var(--content-width);
  --timer-spacing: clamp(0.35rem, 1vh, 1.5rem);
  --teal-rgb: 15, 118, 110;
  --amber-rgb: 244, 193, 79;
  --accent-rgb: var(--amber-rgb);
  --accent-shadow-rgb: var(--accent-rgb);
  --danger-rgb: 243, 67, 54;
  --bg-cold-gradient: linear-gradient(
    145deg,
    #f5f7fb 0%,
    #eef2f6 55%,
    #e6ebf1 100%
  );
  --bg-warm-gradient: linear-gradient(
    145deg,
    #fff4dc 0%,
    #f6ecd3 50%,
    #eef2f7 100%
  );
  --page-bg: var(--bg-warm-gradient);
  --header-bg: rgba(255, 250, 240, 0.96);
  --cool-bg: #f5f7fb;
  --background: var(--cool-bg);
  --card-bg: #ffffff;
  --surface-soft: #f2f5f9;
  --surface-soft-alt: #f3f5f7;
  --panel-warm: #f8f1df;
  --panel-soft: #fff7e3;
  --panel-hover: #f2e7c9;
  --panel-border: #e2d5b8;
  --panel-border-strong: #d5c7a7;
  --text-strong: #0f172a;
  --text-muted: #4b5563;
  --text-secondary: #444;
  --text-olive: #2f3d2f;
  --text-contrast: #fff;
  --text-ink: #111;
  --text-gold: #1b170e;
  --text-accent-dark: #0b360f;
  --text-accent-deeper: #072607;
  --border-subtle: #e5e7eb;
  --border-contrast: #111;
  --disabled-bg: #dcdcdc;
  --disabled-border: #bdbdbd;
  --disabled-text: #6b6b6b;
  --disabled-text-strong: #676767;
  --success: #4caf50;
  --success-strong: #2e7d32;
  --success-bright: #66bb6a;
  --danger: #d32f2f;
  --danger-bright: #e53935;
  --danger-contrast: #b71c1c;
  --danger-gradient: linear-gradient(180deg, #f44336 0%, #c62828 100%);
  --warning-glow: #f9d870;
  --accent-amber-contrast: #3a2e19;
  --danger-dark: #c0392b;
  --badge-frame-dark: #0c0c0c;
  --badge-frame-light: #fdfbf6;
  --badge-gold-frame: var(--accent-amber);
  --badge-core-bg: #fffaf0;
  --glow-soft: #fdfbf6;
  --success-rgb: 76, 175, 80;
  --success-strong-rgb: 46, 125, 50;
  --level-border-rgb: 70, 116, 65;
  --border-hint: #ccc;
  --button-fill-teal: linear-gradient(135deg, #0bbf7d 0%, #0f766e 100%);
  --button-fill-amber: linear-gradient(135deg, #f4c14f 0%, #d89b2d 100%);
  --button-fill: var(--button-fill-amber);
  --accent-amber: #f4c14f;
  --accent-amber-deep: #d89b2d;
  --timer-bg-teal: #e6e2d8;
  --timer-bg-yellow: #fff7e3;
  --timer-fill-teal: var(--button-fill-teal);
  --timer-fill-amber: var(--button-fill-amber);
  --timer-bg: var(--timer-bg-teal);
  --timer-fill: var(--timer-fill-amber);
  --shadow-soft: 0 14px 38px rgba(var(--accent-shadow-rgb), 0.14);
  --shadow-header: 0 8px 28px rgba(15, 23, 42, 0.08);
  --shadow-chip: 0 8px 22px rgba(0, 0, 0, 0.05);
  --shadow-ambient-color: rgba(0, 0, 0, 0.08);
  --scrim-strong: rgba(0, 0, 0, 0.65);
  --tooltip-bg: #fff8e6;
  --card-overlay-strong: rgba(255, 255, 255, 0.86);
  --card-overlay-soft: rgba(255, 255, 255, 0.8);
  --badge-scale: 1;
  --badge-reserve: clamp(120px, 14vh, 160px);
  --header-height: 72px;
  --header-offset: 0px;
  --topbar-height: 20px;
}

/* ========= General Layout ========= */
html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  padding: 0;
  touch-action: none;
  overflow-x: hidden;
}

body {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: stretch;
  min-height: 100vh;
  background: var(--page-bg);
  color: var(--text-strong);
  font-family: 'Inter', 'SF Pro Display', system-ui, sans-serif;
  padding-top: var(--header-height);
  overflow-y: hidden;
  -webkit-font-smoothing: antialiased;
}

.allow-scroll {
  overflow-y: auto !important;
  touch-action: auto !important;
}

body.header-hidden {
  padding-top: 0;
}

button {
  font: inherit;
}

html.no-scroll,
body.no-scroll {
  overflow: hidden !important;
}

/* ========= Header & Account ========= */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: var(--header-bg);
  box-shadow: var(--shadow-header);
  backdrop-filter: blur(8px);
  z-index: 40;
  box-sizing: border-box;
  transition: opacity 200ms ease, transform 200ms ease;
}

.brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  font-weight: 800;
  font-size: 1.5rem;
  letter-spacing: -0.02em;
}

.brand-logo {
  width: 4rem;
  object-fit: contain;
}

.brand-name {
  color: var(--text-strong);
}

.account-area {
  min-width: 140px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  position: relative;
}

.account-button {
  border: none;
  background: var(--button-fill-amber);
  color: var(--text-contrast);
  font-weight: 700;
  padding: 1rem 1.5rem;
  border-radius: 14px;
  box-shadow: 0 10px 24px rgba(var(--accent-shadow-rgb), 0.18);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease, opacity 0.15s ease;
  font-size: 1.5rem;
}

.account-button:hover,
.account-button:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 12px 26px rgba(var(--accent-shadow-rgb), 0.2);
}

.account-button:active {
  transform: translateY(0);
  opacity: 0.9;
}

.site-header__content--brand {
  display: flex;
}

body[data-page='boardSelect'] .site-header__content--brand,
body[data-page='gameplay'] .site-header__content--brand {
  display: none;
}

body[data-page='boardSelect'] .site-header__content--badges,
body[data-page='gameplay'] .site-header__content--badges {
  display: flex;
}

body[data-page='home'] .site-header__content--badges,
body[data-page='difficulty'] .site-header__content--badges {
  display: none;
}

@media (min-width: 900px) {
  .site-header__content {
    max-width: min(92vw, 1080px);
    margin: 0 auto;
    padding-inline: clamp(0.35rem, 1vw, 0.9rem);
  }
}

.account-chip {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  background: var(--button-fill);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  padding: 0.45rem 0.85rem;
  cursor: pointer;
  transition: box-shadow 0.15s ease, transform 0.15s ease,
    border-color 0.15s ease;
  box-shadow: var(--shadow-chip);
}

.account-chip:hover,
.account-chip:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(var(--accent-shadow-rgb), 0.3);
  box-shadow: 0 12px 30px rgba(var(--accent-shadow-rgb), 0.12);
}

.account-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--border-subtle);
  border: 2px solid var(--text-contrast);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
}

.account-name {
  display: inline-flex;
  align-items: center;
  line-height: 1.1;
  font-weight: 700;
  color: var(--text-strong);
  font-size: 0.95rem;
}

.account-area.logged-in .account-name {
  color: var(--text-contrast);
}

.account-menu {
  position: absolute;
  background: var(--card-bg);
  border-radius: 14px;
  border: 1px solid var(--border-subtle);
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.14);
  min-width: 180px;
  padding: 0.4rem;
  display: none;
  flex-direction: column;
  gap: 0.35rem;
  z-index: 10050;
}

.account-menu.open {
  display: flex;
}

.account-menu--floating {
  position: fixed;
}

.account-menu__item {
  border: none;
  background: transparent;
  text-align: left;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  font-weight: 700;
  color: var(--text-strong);
  cursor: pointer;
  transition: background 0.15s ease, transform 0.12s ease;
}

.account-menu__item:hover,
.account-menu__item:focus-visible {
  background: var(--surface-soft);
  transform: translateY(-1px);
}

.account-menu__item:active {
  transform: translateY(0);
}

.site-header__section--center {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 56px;
}

.game-avatar-btn {
  border: 0;
  padding: 0;
  margin: 0;
  background: transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.game-avatar-img {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--text-contrast);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
  background: var(--card-bg);
}

@media (max-width: 520px) {
  .brand-name {
    font-size: 1rem;
  }
  .account-name {
    display: none;
  }
}

body.header-hidden .site-header {
  opacity: 0;
  transform: translateY(-12px);
  pointer-events: none;
}

/* The whole game area is centered and doesn’t resize */
.game-wrapper {
  position: relative;
  width: var(--layout-width);
  max-width: var(--max-board);
  margin: var(--topbar-height) auto 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  max-height: calc(100vh - 2rem);
  padding-top: clamp(0.5rem, 2vh, 1.25rem);
  padding-bottom: 0.75rem;
}

.site-header__content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 100%;
  gap: 1rem;
  flex-wrap: nowrap;
  box-sizing: border-box;
}

.site-header__section {
  display: flex;
  align-items: center;
  flex: 1 1 0;
  min-width: 0;
}

.site-header__section--left {
  justify-content: flex-start;
}

.site-header__section--right {
  justify-content: flex-end;
}

.site-header__content--badges {
  display: none;
  gap: clamp(0.35rem, 1vw, 0.85rem);
}

#goldBadge,
#skillBadge {
  position: static;
  z-index: auto;
  pointer-events: auto;
  opacity: 1;
  transition: opacity 180ms ease, transform 180ms ease;
  transform-origin: center;
  /* width: clamp(110px, 28vw, 150px); */
  /* max-height: calc(var(--header-height) - 16px); */
  display: flex;
  justify-content: center;
  align-items: center;
  box-sizing: border-box;
}

/* Timer + Check: identical container, content swaps */
#timerContainer {
  position: relative;
  width: var(--timer-block-width);
  max-width: var(--max-board);
  height: var(--timer-block-height);
  margin: var(--timer-spacing) auto 0;
  display: block;
  overflow: hidden;
  border-radius: 14px;
}

#timerContainer > * {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: none;
  box-sizing: border-box;
  transform-origin: center;
  transition: opacity 200ms ease, transform 220ms ease;
}

#timerBar {
  background: var(--timer-bg);
}

#timerBar::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--timer-fill);
  transform-origin: left center;
  transform: scaleX(var(--timer-progress, 1));
  transition: transform 120ms linear;
}
#timerBar.no-transition::after {
  transition: none !important;
}

.timer-tip {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-accent-dark);
  text-shadow: -1px 0 var(--text-contrast), 1px 0 var(--text-contrast),
    0 1px var(--text-contrast), 0 -1px var(--text-contrast);
  pointer-events: none;
  opacity: 0;
  transition: opacity 160ms ease;
}

.timer-tip.is-visible {
  opacity: 1;
}

#checkBtn {
  background: var(--button-fill);
  color: var(--text-contrast);
  font-weight: 700;
  font-size: 1.5rem;
  letter-spacing: 0.03em;
  border-radius: 14px;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  pointer-events: none;
  opacity: 0;
  transform: scaleY(0);
  border: none;
}

#checkBtn:disabled {
  cursor: not-allowed;
  box-shadow: none;
  opacity: 0.6;
}

#timerContainer.is-timing #timerBar {
  opacity: 1;
  transform: scaleY(1);
  pointer-events: auto;
}
#timerContainer.is-timing #checkBtn {
  opacity: 0;
  transform: scaleY(0);
  pointer-events: none;
}

#timerContainer.is-check #timerBar {
  opacity: 0;
  transform: scaleY(0);
  pointer-events: none;
}
#timerContainer.is-check #checkBtn {
  opacity: 1;
  transform: scaleY(1);
  pointer-events: auto;
}

/* =========== Bonus ===========*/
#bonusContainer {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: stretch;
  width: var(--content-width);
  max-width: var(--content-width);
  margin: 0.75rem auto 0;
}

button.bonus-button {
  display: flex;
  flex-direction: row;
  align-items: center;
  border-radius: 14px;
  border: 2px solid rgba(var(--accent-shadow-rgb), 0.35);
  background: var(--button-fill);
  border: none;
  color: var(--text-accent-deeper);
  padding: 0.6rem 0.8rem;
  flex: 1;
  cursor: pointer;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.18);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease,
    background 0.2s ease;
}

button.bonus-button .bonus-icon {
  width: 40px;
  height: 40px;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
}

button.bonus-button .bonus-icon img {
  width: 32px;
  height: 32px;
}

button.bonus-button .bonus-label {
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-accent-dark);
  flex: 1;
}

button.bonus-button .bonus-cost {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--text-accent-dark);
  margin-left: auto;
  line-height: 1.1;
}

.bonus-cost-icon {
  width: 26px;
  height: 26px;
  object-fit: contain;
}
.bonus-cost-value {
  display: block;
}

button.bonus-button:hover:not(.disabled) {
  transform: translateY(-2px);
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.25);
}

button.bonus-button.disabled {
  cursor: not-allowed;
  background: var(--disabled-bg);
  border-color: var(--disabled-border);
  color: var(--disabled-text);
  box-shadow: none;
}

button.bonus-button.disabled .bonus-icon {
  background: transparent;
}

button.bonus-button.disabled .bonus-label,
button.bonus-button.disabled .bonus-cost {
  color: var(--disabled-text-strong);
}

/* ========= Go Board ========= */
.board-shell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  max-width: calc(var(--content-width) + 52px);
  background: #fff;
  border: 2px solid rgba(0, 0, 0, 0.35);
  border-radius: 26px;
  padding: 18px;
  margin: clamp(2.6rem, 9vh, 4rem) auto 0;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.08);
  box-sizing: border-box;
}

#board {
  position: relative;
  width: var(--content-width);
  max-width: var(--content-width);
  aspect-ratio: 1 / 1;
  margin: 0;
  background: var(--background);
}

/* grid lines */
.line {
  position: absolute;
  background: black;
  z-index: 0;
}
.line.v {
  top: 0;
  bottom: 0;
  width: 2px;
}
.line.h {
  left: 0;
  right: 0;
  height: 2px;
}

#modeProgressRow {
  margin: 7vh auto 14px;
  text-align: center;
  font-size: 16px;
  line-height: 1.2;
  opacity: 0.9;
  max-width: calc(100vw - 50px);
  white-space: normal;
  color: var(--text-strong);
}

@media (max-width: 480px) {
  #modeProgressRow {
    font-size: 14px;
    margin: 2vh auto 12px;
  }
}

.first-move-hint__text {
  position: absolute;
  display: none;
  top: calc(100% + 12px);
  left: 50%;
  transform: translate(-50%, 0);
  width: 100%;
  max-width: 100%;
  padding: 4px 10px;
  text-align: right;
  white-space: nowrap;
  font-size: 0.95rem;
  line-height: 1.35;
  color: var(--text-muted);
  opacity: 0;
  z-index: 4;
  pointer-events: none;
  transition: opacity 200ms ease;
}

.first-move-hint__text.is-visible {
  display: block;
  opacity: 1;
}

.first-move-hint-target {
  z-index: 3;
}

.first-move-hint-ring {
  position: absolute;
  top: -13%;
  left: -13%;
  width: 120%;
  height: 120%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 2px solid rgba(var(--accent-shadow-rgb), 0.6);
  box-shadow: 0 0 0 6px rgba(var(--accent-shadow-rgb), 0.14);
  animation: firstMoveHintPulse 1.6s ease-in-out infinite;
  pointer-events: none;
  z-index: 3;
}

@keyframes firstMoveHintPulse {
  0% {
    transform: scale(0.88);
    opacity: 0.75;
  }
  50% {
    transform: scale(1.02);
    opacity: 1;
  }
  100% {
    transform: scale(0.9);
    opacity: 0.7;
  }
}

/* hitbox touch points */
.intersection {
  position: absolute;
  width: calc(100% / var(--board-size));
  height: calc(100% / var(--board-size));
  transform: translate(-50%, -50%);
  border-radius: 50%;
  cursor: pointer;
  z-index: 1;
}

/* Stones */
.intersection.black::after,
.intersection.white::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 98%;
  height: 98%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  z-index: 2;
}
.intersection.black::after {
  background: radial-gradient(
      1px 1px at 18% 24%,
      rgba(255, 255, 255, 0.16),
      transparent 55%
    ),
    radial-gradient(
      1.1px 1.1px at 32% 42%,
      rgba(255, 255, 255, 0.14),
      transparent 55%
    ),
    radial-gradient(
      1px 1px at 48% 66%,
      rgba(255, 255, 255, 0.12),
      transparent 55%
    ),
    radial-gradient(
      1px 1px at 62% 30%,
      rgba(255, 255, 255, 0.1),
      transparent 55%
    ),
    radial-gradient(
      1px 1px at 76% 58%,
      rgba(255, 255, 255, 0.1),
      transparent 55%
    ),
    radial-gradient(
      1px 1px at 84% 78%,
      rgba(255, 255, 255, 0.08),
      transparent 55%
    ),
    linear-gradient(135deg, #4a4a4a 0%, #161616 100%);
}
.intersection.white::after {
  background: radial-gradient(
      1px 1px at 16% 22%,
      rgba(0, 0, 0, 0.16),
      transparent 55%
    ),
    radial-gradient(
      1.2px 1.2px at 30% 48%,
      rgba(0, 0, 0, 0.18),
      transparent 55%
    ),
    radial-gradient(1px 1px at 42% 68%, rgba(0, 0, 0, 0.14), transparent 55%),
    radial-gradient(1px 1px at 58% 34%, rgba(0, 0, 0, 0.17), transparent 55%),
    radial-gradient(
      0.9px 0.9px at 70% 62%,
      rgba(0, 0, 0, 0.15),
      transparent 55%
    ),
    radial-gradient(1px 1px at 82% 26%, rgba(0, 0, 0, 0.16), transparent 55%),
    radial-gradient(1px 1px at 88% 78%, rgba(0, 0, 0, 0.14), transparent 55%),
    radial-gradient(1px 1px at 26% 78%, rgba(0, 0, 0, 0.13), transparent 55%),
    radial-gradient(1px 1px at 50% 16%, rgba(0, 0, 0, 0.15), transparent 55%),
    linear-gradient(135deg, #ffffff 0%, #6f6f6f 100%);
  border: 1px solid var(--border-hint);
}

/* markers */
.marker {
  position: absolute;
  font-size: 40px;
  line-height: 1;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 3;
  pointer-events: none;
  opacity: 0.8;
}
.marker--order {
  color: var(--danger-bright);
}

#mainGame {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding-top: 0;
  box-sizing: border-box;
  flex-grow: 1;
  width: 100%;
  max-width: var(--max-board);
  margin: 0 auto;
  position: relative;
}

#feedback {
  position: absolute;
  top: calc(70%);
  background: var(--card-bg);
  border-radius: 15px;
  padding: 1.75rem;
  text-align: center;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  display: none;
  z-index: 10;
  transition: opacity 0.3s ease;
  overflow: hidden;
}

#feedback.show {
  display: flex;
  flex-direction: column;
  align-items: center;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

#feedbackMsg {
  font-size: 1.5rem;
  margin: 0 0 0.5rem 0;
  padding: 0;
}

#feedback button {
  display: block;
  width: min(50vw, 400px);
  max-width: 400px;
  box-sizing: border-box;
  margin: 0.5rem auto;
  font-size: 1.5rem;
  padding: 12px 0;
  border-radius: 10px;
}

/* Make the “Next” button full width */
#nextBtn {
  width: 100%;
  margin: 0.5rem 0;
}

#nextBtn,
#homeBtn2 {
  background: var(--button-fill);
  color: var(--text-contrast);
  border: none;
  box-shadow: 0 12px 24px rgba(var(--accent-shadow-rgb), 0.18);
}

#nextBtn:not(:disabled):hover,
#nextBtn:focus-visible,
#homeBtn2:not(:disabled):hover,
#homeBtn2:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 14px 26px rgba(var(--accent-shadow-rgb), 0.22);
}

#nextBtn:disabled,
#homeBtn2:disabled {
  background: var(--disabled-bg);
  color: var(--disabled-text);
  box-shadow: none;
  cursor: not-allowed;
}

#feedback .feedback-bottom-row {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  gap: 0.5rem;
  justify-content: center;
}

#feedback .feedback-bottom-row button {
  flex: 0 0 auto;
  width: 100%;
  max-width: 400px;
  margin: 0.5rem auto;
}

@media (max-width: 480px) {
  .board-shell {
    margin: 25px auto;
    padding: 14px;
    border-radius: 22px;
  }

  #board {
    width: 60vw;
    max-width: 60vw;
    margin: 0;
  }

  #feedback {
    top: 68%;
    left: 50%;
    transform: translateX(-50%);
    max-width: calc(100vw - 50px);
  }
}

@media (min-height: 640px) {
  #feedback.show {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: clamp(0.5rem, 1.5vh, 0.9rem);
  }
  #feedbackMsg {
    align-self: center;
    font-size: 1.5rem;
    margin-top: 0;
  }
  #feedback .feedback-bottom-row {
    display: grid;
    grid-template-rows: auto auto;
    grid-template-columns: 1fr;
    gap: clamp(0.6rem, 1.8vh, 1rem);
    width: 100%;
    justify-items: center;
  }
  #feedback .feedback-bottom-row button {
    width: clamp(70%, 72vw, 100%);
    max-width: none;
    min-width: 0;
    margin: 0;
    padding: 14px 0;
    min-height: 58px;
    height: 58px;
    font-size: 1.5rem;
    font-weight: 800;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
  }
}

/* ========= Button System ========= */
:where(
    #homeBtn,
    #confirmYes,
    #confirmNo,
    #tutorialOkBtn,
    #tutorialSkipBtn,
    #levelSelectModalGo,
    #levelSelectModalClose,
    #settingsHomeBtn
  ) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: min(320px, 85vw);
  padding: 14px;
  font-size: 1.5rem;
  font-weight: 800;
  background: var(--button-fill);
  color: var(--text-contrast);
  border: none;
  border-radius: 14px;
  cursor: pointer;
  box-shadow: 0 12px 24px rgba(var(--accent-shadow-rgb), 0.18);
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.15s ease;
  margin: 0 auto;
  box-sizing: border-box;
}
:where(
    #homeBtn,
    #confirmYes,
    #confirmNo,
    #tutorialOkBtn,
    #tutorialSkipBtn,
    #levelSelectModalGo,
    #levelSelectModalClose,
    #settingsHomeBtn
  ):hover:not(:disabled),
:where(
    #homeBtn,
    #confirmYes,
    #confirmNo,
    #tutorialOkBtn,
    #tutorialSkipBtn,
    #levelSelectModalGo,
    #levelSelectModalClose,
    #settingsHomeBtn
  ):focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 14px 26px rgba(var(--accent-shadow-rgb), 0.22);
}
:where(
    #homeBtn,
    #confirmYes,
    #confirmNo,
    #tutorialOkBtn,
    #tutorialSkipBtn,
    #levelSelectModalGo,
    #levelSelectModalClose,
    #settingsHomeBtn
  ):disabled {
  background: var(--disabled-bg);
  color: var(--disabled-text);
  box-shadow: none;
  cursor: not-allowed;
}

/* ========= Intro & Difficulty Screens ========= */
#intro,
#difficulty {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--background);
  text-align: center;
  width: 100vw;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  padding: calc(var(--header-height) + 2vh) 1.25rem 2.5rem;
  box-sizing: border-box;
}

#intro.active,
#difficulty.active {
  opacity: 1;
  pointer-events: auto;
}

#intro {
  z-index: 6;
}
#difficulty {
  z-index: 5;
}

.hero {
  /* width: min(520px, 95vw); */
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-soft);
  border-radius: 22px;
  padding: clamp(2rem, 4vw, 2.6rem) clamp(1.5rem, 5vw, 2.8rem);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.4rem;
  text-align: center;
  backdrop-filter: blur(6px);
}

.hero-tagline {
  font-size: clamp(1.8rem, 6vw, 2.6rem);
  font-weight: 800;
  color: var(--text-strong);
  letter-spacing: -0.02em;
  margin: 0;
  line-height: 1.25;
}

.primary-action {
  width: min(320px, 80vw);
  padding: 15px 18px;
  font-size: 1.5rem;
  background: var(--button-fill);
  color: var(--text-contrast);
  border: none;
  border-radius: 16px;
  cursor: pointer;
  font-weight: 800;
  letter-spacing: 0.02em;
  box-shadow: 0 14px 30px rgba(var(--accent-shadow-rgb), 0.22);
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.15s ease;
}

.primary-action:hover,
.primary-action:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 16px 34px rgba(var(--accent-shadow-rgb), 0.25);
}

.primary-action:active {
  transform: translateY(0);
  opacity: 0.92;
  box-shadow: 0 12px 28px rgba(var(--accent-shadow-rgb), 0.2);
}

.secondary-action {
  width: min(320px, 80vw);
  padding: 13px 16px;
  font-size: clamp(17px, 3.6vw, 21px);
  background: var(--surface-soft-alt);
  color: var(--text-strong);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  cursor: pointer;
  font-weight: 750;
  letter-spacing: 0.01em;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.05);
  transition: transform 0.18s ease, box-shadow 0.2s ease, opacity 0.15s ease;
}

.secondary-action:hover,
.secondary-action:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.08);
}

.secondary-action:active {
  transform: translateY(0);
  opacity: 0.9;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.06);
}

.diffBtn {
  display: block;
  width: 100%;
  max-width: min(320px, 80vw);
  min-width: 0;
  margin: 0 auto;
  padding: 15px 18px;
  font-size: clamp(18px, 4vw, 22px);
  background: var(--button-fill);
  color: var(--text-contrast);
  border: none;
  border-radius: 16px;
  font-weight: 800;
  letter-spacing: 0.02em;
  box-shadow: 0 14px 30px rgba(var(--accent-shadow-rgb), 0.22);
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.15s ease;
}

.diffBtn:hover,
.diffBtn:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 16px 34px rgba(var(--accent-shadow-rgb), 0.25);
}

.diffBtn:active {
  transform: translateY(0);
  opacity: 0.92;
  box-shadow: 0 12px 28px rgba(var(--accent-shadow-rgb), 0.2);
}

.diffBtn.locked {
  background: var(--disabled-bg);
  background-image: none;
  border-color: var(--disabled-border);
  color: var(--disabled-text-strong);
  box-shadow: none;
  cursor: not-allowed;
}

.top {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* Shared visuals */
.logo {
  display: block;
  width: 100px;
  object-fit: contain;
  margin: 0;
}

#intro .top,
#difficulty .top {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

#difficulty .top {
  display: none;
}

#intro h1,
#difficulty h1 {
  font-size: clamp(2.5rem, 8vw, 5rem);
  font-weight: 700;
  color: var(--text-ink);
  margin: 10px !important;
}

#intro .subtitle,
#difficulty .subtitle {
  font-size: clamp(1.2rem, 5vw, 2rem);
  text-align: center;
  color: var(--text-strong);
}

.btn-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1em;
}

.mode-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: clamp(12px, 3vw, 20px);
  width: 100%;
  max-width: min(520px, 95vw);
  margin: 0 auto;
  padding: clamp(16px, 4vw, 24px);
  box-sizing: border-box;
  justify-items: stretch;
}

#intro .mode-grid,
#difficulty .mode-grid {
  width: 100%;
}

@media (min-width: 900px) {
  .mode-grid {
    grid-template-columns: 1fr 1fr;
    max-width: min(880px, 96vw);
  }
}

.mode-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(0.35rem, 1vw, 0.7rem);
  padding: clamp(0.9rem, 2vw, 1.2rem);
  background: rgba(255, 255, 255, 0.85);
  border-radius: 16px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.06);
  width: 100%;
  box-sizing: border-box;
}

.mode-card--horizontal {
  flex-direction: row;
  justify-content: flex-start;
  align-items: center;
  gap: clamp(0.75rem, 2.5vw, 1.4rem);
  width: 100%;
}

.mode-icon {
  width: clamp(90px, 22vw, 140px);
  flex-shrink: 0;
}

.mode-icon img {
  width: 100%;
  height: auto;
  display: block;
  max-width: 100%;
}

.mode-content {
  flex: 1 1 auto;
  min-width: 0;
}

.mode-content .diffBtn {
  width: 100%;
  max-width: none;
  min-width: 0;
  display: block;
  margin: 0 auto;
}

.mode-content p {
  word-break: break-word;
  margin: 0.1rem 0 0;
}

.mode-card button {
  width: 100%;
}

/* Level Select Buttons */
.level-select__board-card.locked .level-select__board-icon img,
.level-select__board-card.locked button {
  filter: grayscale(1);
}

.level-select__board-card .diffBtn.locked {
  background: var(--disabled-bg) !important;
  background-image: none !important;
  border-color: var(--disabled-border) !important;
  color: var(--text-ink) !important;
  box-shadow: none;
  cursor: not-allowed;
}

.level-select__stone-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border: none;
  background: var(--button-fill);
  color: var(--text-contrast);
  padding: 0.85rem 1.2rem;
  font-weight: 800;
  font-size: 1.1rem;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease;
  width: 100%;
  max-width: 420px;
  box-sizing: border-box;
}

.level-select__stone-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 14px rgba(0, 0, 0, 0.18);
}

.level-select__stone-btn.selected {
  box-shadow: 0 10px 18px rgba(46, 125, 50, 0.28);
}

.level-select__stone-btn.locked {
  background: var(--disabled-bg) !important;
  background-image: none !important;
  border-color: var(--disabled-border) !important;
  color: var(--text-ink) !important;
  cursor: not-allowed;
  box-shadow: none;
}

.level-select__stone-btn-wrap {
  display: flex;
  justify-content: center;
  width: 100%;
}
.mode-card.level-select__board-card .level-select__stone-btn,
.level-select__stone-btn-wrap .level-select__stone-btn {
  width: clamp(140px, 40vw, 200px);
  min-width: 140px;
  max-width: 200px;
  align-self: center;
}

.level-select__back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  padding: 0.65rem 0.9rem;
  min-width: 92px;
  width: min(320px, 100%);
  justify-self: start;
  background: var(--button-fill);
  color: var(--text-contrast);
  border: none;
  font-weight: 800;
  box-shadow: 0 12px 24px rgba(var(--accent-shadow-rgb), 0.18);
  transition: transform 0.18s ease, box-shadow 0.2s ease, opacity 0.15s ease;
}

.level-select__back:hover,
.level-select__back:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 14px 26px rgba(var(--accent-shadow-rgb), 0.22);
}

.level-select__back:disabled {
  background: var(--disabled-bg);
  color: var(--disabled-text);
  box-shadow: none;
  cursor: not-allowed;
}

@media (max-width: 540px) {
  .level-select__back {
    justify-self: center;
  }
}

.mode-status {
  font-size: 0.75rem;
  letter-spacing: 0.3em;
  color: var(--text-ink);
  text-transform: uppercase;
  margin: 0;
  padding-top: 0.35rem;
}

.btn-col button {
  width: clamp(200px, 60vw, 400px);
  font-size: clamp(1rem, 5vw, 1.5rem);

  border-radius: 14px;
  background: var(--button-fill);
  border: none;
  color: var(--text-contrast);
  font-weight: 600;
  letter-spacing: 0.02em;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.18);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn-col button:hover:not(.disabled),
.btn-col button:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.25);
}

.btn-col button:disabled {
  background: var(--disabled-bg);
  border-color: var(--disabled-border);
  color: var(--disabled-text);
  box-shadow: none;
}

/* ========= Disabled Intersection ========= */
.intersection[style*='pointer-events: none'] {
  cursor: not-allowed;
}

/* ========== Settings Page ==============*/
#settingsModal {
  position: fixed;
  inset: 0;
  display: none;
  padding: 20px;
  background: var(--background);
  overflow-y: auto;
  z-index: 7;
}

#settingsModal.active {
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.settings-content {
  max-width: 450px;
  margin: 0 auto;
  background: var(--panel-warm);
  padding: 20px;
  border-radius: 12px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.settings-content h2 {
  margin-top: 0;
  margin-bottom: 8px;
}

.setting-group {
  background: var(--panel-soft);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 16px;
}

.setting-group h3 {
  margin: 0 0 10px 0;
  font-size: 1rem;
}

.tap-mode-option {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.tap-mode-option:hover {
  background: var(--panel-hover);
  border-color: var(--panel-border-strong);
}

.tap-mode-option input {
  margin-top: 4px;
}

.option-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.option-title {
  font-weight: 700;
}

.option-desc {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.35;
}

.settings-about h3 {
  margin-bottom: 6px;
}

.settings-about p {
  margin: 0 0 10px 0;
  line-height: 1.4;
}

.settings-actions {
  display: flex;
  justify-content: center;
  margin-top: 14px;
}

.green-btn {
  background-color: var(--success);
  color: var(--text-contrast);
  font-size: 1rem;
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  margin-top: 15px;
}

/* ========== Restart Confirmation ==============*/
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--scrim-strong);
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: var(--panel-warm);
  padding: 20px;
  border-radius: 10px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.modal-content button {
  padding: 12px 0;

  border-radius: 10px;
  cursor: pointer;
  font-size: 1rem;
}

.modal-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  justify-content: center;
  margin-top: 15px;
  width: 100%;
}

.modal-buttons button {
  flex: 1 1 auto;
  min-width: 120px;
  width: 100%;
  max-width: 320px;
  align-self: center;
}

#confirmYes {
  background: var(--danger-gradient) !important;
  color: white !important;
  border: 2px solid var(--danger-contrast) !important;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.22) !important;
  width: 100%;
}

#confirmNo {
  background-color: var(--success);
  color: var(--text-contrast);
}

#gameHeader {
  display: grid;
  grid-template-columns: 1fr;
  min-width: 80px;
  align-items: center;
  width: auto;
  flex: 0 1 28%;
  max-width: 30vw;
  min-width: 0;
  gap: 0.08rem;
  margin: 0;
  text-align: center;
}

#levelInfo {
  margin: 0;
  padding: 0;
  line-height: 1.1;
  display: inline-block;
  font-size: clamp(0.6rem, 1.2vw + 0.5vh, 1rem);
  font-weight: 600;
  text-align: center;
}

#levelInfo {
  text-align: center;
  width: auto;
  max-width: 70vw;
}

.site-header__content--badges .badge {
  flex: 0 0 auto;
  width: clamp(110px, 28vw, 150px);
  /* max-height: calc(var(--header-height) - 16px); */
  display: flex;
  align-items: center;
  justify-content: center;
  /* transform: scale(calc(var(--badge-scale) * 0.9)); */
  transform-origin: center;
  opacity: 0;
  transition: opacity 160ms ease;
}

body.badges-visible:not(.badges-hidden) .site-header__content--badges .badge {
  opacity: 1;
  pointer-events: auto;
}

.badges-hidden .site-header__content--badges .badge {
  opacity: 0;
  pointer-events: none;
}

.skill-badge__frame {
  position: relative;
  background: conic-gradient(
    from 215deg,
    var(--badge-frame-dark) 0deg 205deg,
    var(--badge-frame-light) 205deg 360deg
  );
  /* Thinner frame padding to shrink badge frame without changing text size */
  padding: 0.3rem 0.3rem;
  border-radius: 26px;
  box-shadow: none;
  overflow: hidden;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  box-shadow: 10px 5px 5px rgba(var(--accent-shadow-rgb), 0.18);
}

.skill-badge__frame::before {
  content: '';
  position: absolute;
  inset: 0.28rem;
  border-radius: 22px;
  background: linear-gradient(
      135deg,
      rgba(255, 255, 255, 0.65),
      rgba(255, 255, 255, 0)
    )
    center/140% 140% no-repeat;
  mix-blend-mode: screen;
  opacity: 0.42;
  z-index: 0;
}

.skill-badge__core {
  background: var(--card-bg);
  border: 2px solid var(--border-contrast);
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.18rem;
  position: relative;
  z-index: 1;
}

.skill-badge__value {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-ink);
  line-height: 1;
}

.skill-badge__label {
  font-size: clamp(0.75rem, 1vw + 0.24vh, 1rem);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-ink);
  line-height: 1.05;
}

#goldBadge {
  position: static;
  z-index: auto;
  pointer-events: auto;
  opacity: 1;
  transition: opacity 180ms ease, transform 180ms ease;
  transform-origin: center;
  display: flex;
  justify-content: center;
  align-items: center;
  box-sizing: border-box;
}

.gold-badge__frame {
  position: relative;
  background: conic-gradient(
    from 215deg,
    var(--badge-frame-dark) 0deg 205deg,
    var(--badge-gold-frame) 205deg 360deg
  );
  padding: 0.3rem 0.3rem;
  border-radius: 26px;
  box-shadow: none;
  overflow: hidden;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  box-shadow: 10px 5px 5px rgba(var(--accent-shadow-rgb), 0.18);
}

.gold-badge__frame::before {
  content: '';
  position: absolute;
  inset: 0.28rem;
  border-radius: 22px;
  background: linear-gradient(
      145deg,
      rgba(255, 248, 220, 0.7),
      rgba(255, 248, 220, 0)
    )
    center/140% 140% no-repeat;
  mix-blend-mode: screen;
  opacity: 0.45;
  z-index: 0;
}

.gold-badge__core {
  background: var(--badge-core-bg);
  border: 2px solid var(--border-contrast);
  border-radius: 18px;
  /* padding: 0.2rem 0.2rem; */
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.18rem;
  position: relative;
  z-index: 1;
}

.gold-badge__value {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-ink);
  line-height: 1;
}

.gold-badge__label {
  font-size: clamp(0.75rem, 1vw + 0.24vh, 1rem);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-ink);
  line-height: 1.05;
}

.mode-chip {
  padding: 0.25rem 0.8rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.08);
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.08em;
  font-size: clamp(0.7rem, 1.3vw + 0.3vh, 1rem);
  color: var(--text-gold);
}

.gold-alert {
  animation: goldAlertPulse 0.45s ease;
}

@keyframes goldAlertPulse {
  0% {
    transform: scale(1);
  }
  30% {
    transform: scale(1.3);
    color: var(--danger);
  }
  70% {
    transform: scale(1.05);
    color: var(--danger);
  }
  100% {
    transform: scale(1);
    color: var(--text-accent-deeper);
  }
}

#tutorialOverlay,
#tutorialHighlight {
  z-index: 90;
}

.tutorial-hidden {
  display: none !important;
}

.tutorial-overlay {
  position: fixed;
  inset: 0;
  background: var(--scrim-strong);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.tutorial-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.tutorial-highlight {
  position: fixed;
  border: 3px solid var(--text-contrast);
  border-radius: 16px;
  box-shadow: 0 0 15px rgba(0, 0, 0, 0.4);
  padding: 8px;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.tutorial-highlight.active {
  opacity: 1;
}

.tutorial-tooltip {
  position: fixed;
  background: var(--tooltip-bg);
  color: var(--accent-amber-contrast);
  padding: 1rem;
  border-radius: 14px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  max-width: min(90vw, 400px);
  transform: translate(-50%, -50%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  text-align: left;
  z-index: 120;
}

.tutorial-tooltip.active {
  opacity: 1;
  pointer-events: auto;
}

.tutorial-tooltip button {
  margin-top: 0.75rem;
  width: 100%;
  font-size: 1rem;
}

.tutorial-skip {
  position: fixed;
  top: auto;
  left: 50%;
  transform: translate(-50%, 0);
  background: rgba(255, 255, 255, 0.95);
  border-radius: 10px;
  padding: 0.35rem 0.45rem;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 130;
}

.tutorial-skip.active {
  opacity: 1;
  pointer-events: auto;
}

.tutorial-skip button {
  margin: 0;
  padding: 0.35rem 0.75rem;
  font-size: 1.5rem;
  line-height: 1.2;
  min-width: 120px;
  white-space: normal;
}

.tutorial-pulse {
  animation: tutorialPulse 1.4s ease-in-out infinite;
}

@keyframes tutorialPulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.7);
  }
  70% {
    transform: scale(1.05);
    box-shadow: 0 0 0 12px rgba(255, 255, 255, 0);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(255, 255, 255, 0);
  }
}

#goldPopup {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 10;
}

.gold-float,
.rating-float {
  position: fixed;
  top: 8px;
  pointer-events: none;
  font-size: 1.3rem;
  font-weight: 700;
  opacity: 0;
  z-index: 9995;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
  display: inline-block;
}

.gold-float {
  left: 140px;
  color: var(--accent-amber);
  text-shadow: -1px 0 var(--text-ink), 1px 0 var(--text-ink),
    0 1px var(--text-ink), 0 -1px var(--text-ink), 0 0 6px var(--warning-glow),
    0 0 12px rgba(249, 216, 112, 0.85), 0 0 18px rgba(249, 216, 112, 0.65);
}

.gold-float--deduct {
  color: var(--danger-dark);
}

.gold-float--anchored {
  position: absolute;
  left: 0;
  top: 0;
}

.gold-float-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  opacity: 1;
}

.gold-float-stack.gold-float--anchored {
  transform: none !important;
}

.rating-float-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  opacity: 1;
}

.rating-float-stack.rating-float--anchored {
  transform: none !important;
}

.rating-float {
  right: 140px;
  color: var(--text-ink);
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-shadow: -1px 0 var(--glow-soft), 1px 0 var(--glow-soft),
    0 1px var(--glow-soft), 0 -1px var(--glow-soft),
    0 0 10px rgba(255, 255, 255, 0.9);
}

.rating-float--anchored {
  position: absolute;
  left: 0;
  top: 0;
}

.level-up-overlay {
  display: none !important;
}

.level-up-overlay__text {
  display: none;
}

.level-up-overlay__actions {
  display: none;
}

.level-up-overlay__btn {
  display: none;
}

.level-up-overlay__btn--ghost {
  background: var(--card-bg);
  color: var(--success-strong);
  box-shadow: inset 0 0 0 2px rgba(var(--success-strong-rgb), 0.4);
}

.timer-toast {
  position: absolute;
  top: -26px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--text-contrast);
  padding: 4px 10px;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  pointer-events: none;
  z-index: 20;
}

.hint-stone {
  position: absolute;
  width: calc(100% / var(--board-size));
  height: calc(100% / var(--board-size));
  border-radius: 50%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 4;
  pointer-events: none;
  opacity: 0;
}
.hint-stone.white {
  background: var(--text-contrast);
  border: 2px solid var(--border-hint);
}
.hint-stone.black {
  background: var(--text-ink);
}

@media (max-width: 640px) {
  .site-header__content--badges {
    gap: clamp(0.2rem, 0.8vw, 0.6rem);
  }
  /* Removing fixed badge width on small screens to keep badges lighter and avoid chunky look */
  #gameHeader {
    font-size: 0.95em;
    flex: 0 1 24%;
    max-width: 26vw;
    min-width: 60px;
  }
}

@keyframes goldPulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.4);
    color: var(--success-bright);
  }
  100% {
    transform: scale(1);
    color: inherit;
  }
}

@keyframes goldDeduct {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.4);
    color: var(--danger-bright); /* red tone */
  }
  100% {
    transform: scale(1);
    color: inherit;
  }
}
