:root {
  --line: rgba(198, 226, 255, 0.14);
  --text: #f5f7fb;
  --muted: #bfd0df;
  --panel: rgba(9, 21, 34, 0.76);
  --chip: rgba(255, 255, 255, 0.05);
  --accent: #7dd8ff;
  --add: #67cf94;
  --subtract: #f37d7d;
  --multiply: #b48af3;
  --divide: #f3bf74;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
  --shadow-soft: 0 10px 28px rgba(0, 0, 0, 0.18);
  --overlay-safe-top: clamp(58px, 7vw, 84px);
  --overlay-safe-bottom: clamp(40px, 6vw, 56px);
  --safe-area-top: env(safe-area-inset-top, 0px);
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
  --safe-area-left: env(safe-area-inset-left, 0px);
  --safe-area-right: env(safe-area-inset-right, 0px);
  --visible-viewport-height: 100svh;
  --body-background:
    radial-gradient(circle at top, rgba(248, 186, 201, 0.18), transparent 28%),
    linear-gradient(180deg, rgba(7, 15, 26, 0.28), rgba(7, 15, 26, 0.72)),
    linear-gradient(160deg, #0a1621, #14273a 48%, #172d40);
  --backdrop-background:
    url("./assets/ninja-background-bamboo-dojo.png") center center / cover no-repeat;
  --backdrop-opacity: 1;
  --backdrop-glow: transparent;
  --shell-background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0)),
    linear-gradient(160deg, rgba(9, 32, 26, 0.5), rgba(32, 20, 12, 0.56));
  --slot-ghost-border: rgba(255, 255, 255, 0.08);
  --slot-ghost-background: rgba(255, 255, 255, 0.02);
  --card-background:
    radial-gradient(circle at 50% 18%, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0) 56%),
    linear-gradient(180deg, rgba(36, 58, 78, 0.9), rgba(13, 29, 44, 0.94) 64%, rgba(10, 23, 36, 0.96));
  --card-border: rgba(164, 205, 234, 0.08);
  --card-shadow:
    0 10px 22px rgba(4, 10, 18, 0.14),
    0 20px 42px rgba(2, 8, 15, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    inset 0 -10px 18px rgba(3, 10, 18, 0.08);
  --card-before-background:
    radial-gradient(circle at 50% 0%, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0) 44%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0) 28%, rgba(3, 9, 16, 0.05) 100%);
  --card-hover-border: rgba(125, 216, 255, 0.14);
  --card-hover-shadow:
    0 14px 26px rgba(4, 10, 18, 0.16),
    0 24px 46px rgba(3, 9, 16, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    inset 0 -8px 16px rgba(3, 10, 18, 0.06);
  --card-selected-background:
    radial-gradient(circle at 50% 18%, rgba(125, 216, 255, 0.14), rgba(255, 255, 255, 0) 54%),
    linear-gradient(180deg, rgba(32, 62, 86, 0.96), rgba(11, 31, 46, 0.98) 62%, rgba(8, 24, 37, 1));
  --card-selected-shadow:
    0 0 0 1px rgba(125, 216, 255, 0.44),
    0 0 0 8px rgba(125, 216, 255, 0.12),
    0 22px 38px rgba(18, 142, 189, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  --card-result-background:
    radial-gradient(circle at 50% 18%, rgba(111, 227, 175, 0.1), rgba(255, 255, 255, 0) 54%),
    linear-gradient(180deg, rgba(20, 49, 59, 0.96), rgba(9, 24, 35, 0.98) 62%, rgba(7, 20, 30, 1));
}

:root[data-theme="light"] {
  --line: rgba(94, 135, 96, 0.24);
  --text: #143528;
  --muted: #4f725e;
  --chip: rgba(233, 249, 231, 0.42);
  --shadow: 0 20px 46px rgba(40, 73, 45, 0.2);
  --shadow-soft: 0 12px 26px rgba(45, 79, 50, 0.14);
  --body-background:
    radial-gradient(circle at top, rgba(255, 208, 174, 0.42), transparent 34%),
    linear-gradient(180deg, rgba(251, 253, 255, 0.94), rgba(231, 240, 248, 0.96)),
    linear-gradient(160deg, #f7fbff, #eaf2f8 48%, #dfeaf3);
  --backdrop-background:
    url("./assets/ninja-background-bamboo-dojo.png") center center / cover no-repeat;
  --backdrop-opacity: 1;
  --backdrop-glow: transparent;
  --shell-background:
    radial-gradient(circle at 22% 0%, rgba(255, 244, 200, 0.28), rgba(255, 255, 255, 0) 42%),
    linear-gradient(180deg, rgba(244, 255, 238, 0.58), rgba(218, 244, 216, 0.38)),
    rgba(234, 250, 229, 0.46);
  --slot-ghost-border: rgba(86, 132, 90, 0.2);
  --slot-ghost-background: rgba(236, 250, 231, 0.34);
  --card-background:
    radial-gradient(circle at 50% 14%, rgba(255, 251, 226, 0.82), rgba(255, 255, 255, 0) 58%),
    linear-gradient(180deg, rgba(238, 252, 234, 0.96), rgba(216, 240, 216, 0.96) 62%, rgba(196, 226, 204, 0.98));
  --card-border: rgba(96, 145, 93, 0.24);
  --card-shadow:
    0 10px 18px rgba(64, 101, 61, 0.13),
    0 18px 30px rgba(74, 111, 68, 0.15),
    inset 0 1px 0 rgba(255, 255, 246, 0.74),
    inset 0 -10px 18px rgba(114, 154, 100, 0.12);
  --card-before-background:
    radial-gradient(circle at 50% 0%, rgba(255, 255, 238, 0.7), rgba(255, 255, 255, 0) 48%),
    linear-gradient(180deg, rgba(255, 255, 241, 0.14), rgba(255, 255, 255, 0) 34%, rgba(94, 135, 82, 0.08) 100%);
  --card-hover-border: rgba(103, 157, 93, 0.34);
  --card-hover-shadow:
    0 12px 22px rgba(67, 106, 64, 0.16),
    0 20px 34px rgba(87, 129, 76, 0.18),
    inset 0 1px 0 rgba(255, 255, 242, 0.8),
    inset 0 -8px 16px rgba(117, 151, 98, 0.08);
  --card-selected-background:
    radial-gradient(circle at 50% 18%, rgba(255, 232, 151, 0.34), rgba(255, 255, 255, 0) 58%),
    linear-gradient(180deg, rgba(231, 252, 222, 0.99), rgba(199, 235, 197, 1) 62%, rgba(177, 218, 188, 1));
  --card-selected-shadow:
    0 0 0 1px rgba(100, 154, 86, 0.38),
    0 0 0 8px rgba(135, 187, 100, 0.14),
    0 18px 28px rgba(84, 132, 73, 0.2),
    inset 0 1px 0 rgba(255, 255, 238, 0.76);
  --card-result-background:
    radial-gradient(circle at 50% 18%, rgba(134, 218, 146, 0.28), rgba(255, 255, 255, 0) 58%),
    linear-gradient(180deg, rgba(232, 251, 229, 0.99), rgba(205, 238, 206, 1) 62%, rgba(184, 224, 193, 1));
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  min-height: var(--visible-viewport-height);
  overflow-x: hidden;
  overflow-y: auto;
  font-family: "Avenir Next", "Trebuchet MS", sans-serif;
  color: var(--text);
  background: var(--body-background);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

.page-backdrop {
  position: fixed;
  inset: 0;
  background: var(--backdrop-background);
  opacity: var(--backdrop-opacity);
  pointer-events: none;
}

.page-backdrop::before {
  content: "";
  position: absolute;
  width: min(42vw, 420px);
  aspect-ratio: 1;
  top: 9%;
  left: 50%;
  transform: translateX(-50%);
  border-radius: 999px;
  background: var(--backdrop-glow);
  filter: blur(10px);
}

.site-brand-link {
  position: fixed;
  top: calc(clamp(12px, 2vw, 22px) + var(--safe-area-top));
  left: calc(clamp(12px, 2vw, 22px) + var(--safe-area-left));
  z-index: 3;
  width: clamp(96px, 8vw, 132px);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
  opacity: 0.96;
  transition: transform 180ms ease, opacity 180ms ease, filter 180ms ease;
}

.site-brand-link:hover {
  transform: translateY(-1px) scale(1.02);
  opacity: 1;
  filter: brightness(1.03);
}

.site-brand-link img {
  display: block;
  width: 100%;
  height: auto;
  filter: drop-shadow(0 8px 22px rgba(0, 0, 0, 0.26));
}

.site-footer {
  position: fixed;
  left: 50%;
  bottom: calc(clamp(10px, 1.8vw, 18px) + var(--safe-area-bottom));
  z-index: 3;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100vw - 24px);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  color: rgba(226, 233, 240, 0.82);
  font-size: clamp(0.88rem, 1.45vw, 1.06rem);
  font-weight: 500;
  line-height: 1;
  white-space: normal;
  text-align: center;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.28);
}

.site-footer__copy {
  display: inline-block;
}

.site-footer__separator {
  color: rgba(226, 233, 240, 0.62);
}

.site-footer__link {
  color: inherit;
  text-underline-offset: 0.14em;
  text-decoration-thickness: 0.08em;
}

.site-footer__link:hover {
  color: rgba(245, 247, 251, 0.96);
}

:root[data-theme="light"] .site-brand-link img {
  filter: drop-shadow(0 8px 18px rgba(92, 121, 146, 0.18));
}

:root[data-theme="light"] .site-footer {
  color: rgba(18, 49, 36, 0.84);
  text-shadow:
    0 1px 8px rgba(244, 255, 235, 0.86),
    0 0 2px rgba(244, 255, 235, 0.72);
}

:root[data-theme="light"] .site-footer__separator {
  color: rgba(18, 49, 36, 0.58);
}

:root[data-theme="light"] .site-footer__link:hover {
  color: rgba(8, 35, 23, 0.96);
}

:root[data-theme="light"] .about-game {
  background:
    radial-gradient(circle at 16% 0%, rgba(255, 241, 190, 0.24), rgba(255, 255, 255, 0) 42%),
    linear-gradient(180deg, rgba(245, 255, 239, 0.56), rgba(225, 246, 221, 0.46)),
    rgba(235, 250, 230, 0.5);
}

.app-shell {
  position: relative;
  min-height: calc(100svh - 130px - var(--safe-area-bottom));
  padding:
    calc(var(--overlay-safe-top) + var(--safe-area-top))
    calc(clamp(16px, 2vw, 28px) + var(--safe-area-right))
    18px
    calc(clamp(16px, 2vw, 28px) + var(--safe-area-left));
  display: flex;
  align-items: center;
  justify-content: center;
}

.page-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-height: var(--visible-viewport-height);
}

.game-shell {
  width: min(100%, 860px);
  height: min(100%, 860px);
  max-height: calc(100svh - var(--overlay-safe-top) - var(--overlay-safe-bottom) - var(--safe-area-top) - var(--safe-area-bottom));
  padding: clamp(20px, 2.2vw, 30px);
  border: 1px solid var(--line);
  border-radius: 36px;
  background: var(--shell-background);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.seo-content {
  width: 100%;
  padding:
    0
    calc(clamp(16px, 2vw, 28px) + var(--safe-area-right))
    calc(52px + var(--safe-area-bottom))
    calc(clamp(16px, 2vw, 28px) + var(--safe-area-left));
}

.about-game {
  width: min(100%, 860px);
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0)),
    rgba(7, 17, 29, 0.5);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

.about-game__summary {
  list-style: none;
  padding: 13px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}

.about-game__summary::-webkit-details-marker {
  display: none;
}

.about-game__summary::after {
  content: "";
  width: 10px;
  height: 10px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  transition: transform 180ms ease;
  opacity: 0.8;
}

.about-game[open] .about-game__summary::after {
  transform: rotate(225deg);
}

.about-game__summary:focus-visible {
  outline: 2px solid rgba(125, 216, 255, 0.9);
  outline-offset: -2px;
}

.about-game__content {
  padding: 0 clamp(18px, 2.5vw, 24px) clamp(18px, 2.5vw, 24px);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.about-game__content h2 {
  margin: 0;
  font-family: Georgia, "Palatino Linotype", serif;
  font-size: clamp(1.2rem, 1.7vw, 1.5rem);
  line-height: 1.1;
}

.about-game__content h2 + p {
  margin-top: 0.55rem;
}

.about-game__content h2:not(:first-child) {
  margin-top: 1.1rem;
}

.about-game__content p {
  margin: 0 0 1.1rem;
  max-width: 70ch;
  color: var(--muted);
  font-size: clamp(0.98rem, 1.18vw, 1.05rem);
  line-height: 1.6;
}

.about-game__content p:last-child {
  margin-bottom: 0;
}

:root[data-theme="light"] .about-game__content {
  border-top-color: rgba(93, 123, 149, 0.12);
}

.hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.hero__copy {
  min-width: 0;
}

.hero h1 {
  margin: 0;
  font-family: Georgia, "Palatino Linotype", serif;
  font-size: clamp(2rem, 3.2vw, 3.2rem);
  line-height: 0.96;
  letter-spacing: -0.015em;
  font-variant-numeric: lining-nums;
  text-wrap: balance;
}

.hero-title__lead,
.hero-title__rest {
  display: inline-block;
  white-space: nowrap;
}

.hero-title__lead {
  font-size: 1.08em;
  font-weight: 700;
  transform: translateY(0.01em);
  margin-right: -0.02em;
}

.hero__subtitle {
  margin: 0.45rem 0 0;
  color: var(--muted);
  font-size: clamp(0.92rem, 1.1vw, 1rem);
}

.hero-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.hero-chip {
  min-width: 112px;
  height: 48px;
  padding: 0 14px;
  border-radius: 20px;
  border: 1px solid rgba(125, 216, 255, 0.18);
  background: linear-gradient(180deg, rgba(125, 216, 255, 0.16), rgba(125, 216, 255, 0.06));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: left;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.hero-chip--muted {
  background: var(--chip);
  border-color: rgba(255, 255, 255, 0.08);
}

.hero-chip__label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-transform: none;
  color: rgba(226, 236, 246, 0.68);
  line-height: 1;
}

.hero-chip__value {
  display: inline-block;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.hero-chip__metrics {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.hero-chip__best {
  display: inline-flex;
  align-items: center;
  gap: 0.35ch;
  color: var(--muted);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.hero-button {
  min-width: 104px;
  height: 48px;
  padding: 0 14px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.045);
  color: rgba(241, 247, 252, 0.92);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition:
    transform 180ms ease,
    background 180ms ease,
    border-color 180ms ease,
    color 180ms ease,
    box-shadow 180ms ease;
}

.hero-button:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.075);
  border-color: rgba(255, 255, 255, 0.16);
}

.hero-button.is-confirming {
  background: rgba(243, 121, 121, 0.12);
  border-color: rgba(243, 121, 121, 0.34);
  color: #fff4f4;
  box-shadow: 0 0 0 6px rgba(243, 121, 121, 0.08);
}

.hero-button--theme .control-label {
  min-width: 4ch;
  text-align: center;
}

.hero-button--theme.is-active {
  border-color: rgba(255, 224, 140, 0.28);
  background: linear-gradient(180deg, rgba(255, 224, 140, 0.18), rgba(255, 224, 140, 0.08));
  color: rgba(255, 246, 210, 0.96);
}

.control-icon {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.control-icon--chip {
  width: 14px;
  height: 14px;
  color: rgba(125, 216, 255, 0.86);
}

.control-label {
  display: inline-block;
  line-height: 1;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

:root[data-theme="light"] .hero-chip {
  border-color: rgba(102, 146, 92, 0.22);
  background: linear-gradient(180deg, rgba(238, 252, 231, 0.48), rgba(216, 242, 212, 0.24));
}

:root[data-theme="light"] .hero-chip--muted {
  background: rgba(238, 250, 231, 0.28);
  border-color: rgba(102, 138, 87, 0.18);
}

:root[data-theme="light"] .hero-chip__label {
  color: rgba(70, 101, 73, 0.78);
}

:root[data-theme="light"] .control-icon--chip {
  color: rgba(70, 141, 88, 0.9);
}

:root[data-theme="light"] .hero-button {
  border-color: rgba(99, 135, 85, 0.2);
  background: rgba(240, 252, 233, 0.4);
  color: rgba(20, 53, 40, 0.92);
  box-shadow: 0 6px 18px rgba(88, 123, 78, 0.12);
}

:root[data-theme="light"] .hero-button:hover {
  background: rgba(247, 255, 239, 0.58);
  border-color: rgba(96, 145, 83, 0.3);
}

:root[data-theme="light"] .hero-button.is-confirming {
  background: rgba(243, 121, 121, 0.18);
  border-color: rgba(218, 100, 100, 0.34);
  color: #7b1f24;
  box-shadow: 0 0 0 6px rgba(243, 121, 121, 0.1);
}

:root[data-theme="light"] .hero-button--theme.is-active {
  background: linear-gradient(180deg, rgba(255, 232, 155, 0.38), rgba(236, 205, 111, 0.18));
  border-color: rgba(177, 139, 49, 0.36);
  color: rgba(82, 61, 11, 0.94);
  box-shadow: 0 8px 18px rgba(174, 143, 68, 0.18);
}

.play-panel {
  min-height: 0;
  flex: 1;
  display: flex;
}

.play-stage {
  width: min(100%, 560px);
  min-height: 0;
  margin: 0 auto;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 18px;
  align-content: center;
  justify-items: center;
}

.board-wrap {
  position: relative;
  min-height: 0;
  display: grid;
  align-content: center;
  justify-items: center;
}

.control-dock {
  display: grid;
  justify-items: center;
  gap: 14px;
}

.success-toast {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translate(-50%, 12px) scale(0.94);
  padding: 10px 18px;
  border-radius: 999px;
  border: 1px solid rgba(103, 207, 148, 0.42);
  background: linear-gradient(180deg, rgba(36, 86, 57, 0.94), rgba(19, 58, 37, 0.92));
  color: #f4fff7;
  font-size: 0.96rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  white-space: nowrap;
  box-shadow:
    0 16px 34px rgba(4, 18, 11, 0.32),
    0 0 0 1px rgba(255, 255, 255, 0.06) inset;
  backdrop-filter: blur(10px);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 180ms ease,
    transform 220ms ease;
  z-index: 2;
}

.success-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}

.success-toast.is-error {
  border-color: rgba(243, 125, 125, 0.42);
  background: linear-gradient(180deg, rgba(118, 39, 45, 0.95), rgba(88, 27, 33, 0.92));
  color: #fff5f5;
  box-shadow:
    0 16px 34px rgba(32, 9, 11, 0.3),
    0 0 0 1px rgba(255, 255, 255, 0.05) inset;
}

:root[data-theme="light"] .success-toast {
  border-color: rgba(84, 168, 117, 0.42);
  background: linear-gradient(180deg, rgba(225, 248, 231, 0.99), rgba(200, 236, 210, 0.97));
  color: #10341f;
  box-shadow:
    0 14px 30px rgba(103, 141, 118, 0.22),
    0 0 0 1px rgba(255, 255, 255, 0.72) inset;
}

:root[data-theme="light"] .success-toast.is-error {
  border-color: rgba(204, 110, 110, 0.4);
  background: linear-gradient(180deg, rgba(255, 236, 236, 0.99), rgba(248, 212, 212, 0.96));
  color: #681d23;
  box-shadow:
    0 14px 30px rgba(167, 119, 119, 0.22),
    0 0 0 1px rgba(255, 255, 255, 0.7) inset;
}

.board-grid {
  width: min(100%, min(420px, 48vh));
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(14px, 2vw, 18px);
}

.board-slot {
  position: relative;
  min-width: 0;
}

.number-card,
.slot-ghost,
.operator-button,
.action-button {
  appearance: none;
  border: 0;
}

.slot-ghost {
  width: 100%;
  height: 100%;
  min-height: 98px;
  border-radius: 28px;
  border: 1px dashed var(--slot-ghost-border);
  background: var(--slot-ghost-background);
}

.number-card {
  width: 100%;
  height: 100%;
  min-height: 98px;
  padding: 16px;
  position: relative;
  overflow: hidden;
  border-radius: 28px;
  background: var(--card-background);
  color: var(--text);
  border: 1px solid var(--card-border);
  box-shadow: var(--card-shadow);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition:
    transform 180ms ease,
    border-color 180ms ease,
    box-shadow 180ms ease,
    background 180ms ease,
    opacity 180ms ease,
    filter 180ms ease;
}

.number-card::after {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 22px;
  border: 2px solid transparent;
  opacity: 0;
  transition: opacity 180ms ease, border-color 180ms ease;
}

.number-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--card-before-background);
  pointer-events: none;
}

.number-card:hover:not([disabled]) {
  transform: translateY(-1px);
  border-color: var(--card-hover-border);
  box-shadow: var(--card-hover-shadow);
}

.number-card.is-selected {
  transform: translateY(-2px) scale(1.035);
  border-color: rgba(125, 216, 255, 0.82);
  background: var(--card-selected-background);
  box-shadow: var(--card-selected-shadow);
}

.number-card.is-selected::after {
  opacity: 1;
  border-color: rgba(125, 216, 255, 0.9);
}

:root[data-theme="light"] .number-card.is-selected {
  border-color: rgba(105, 155, 85, 0.72);
}

:root[data-theme="light"] .number-card.is-selected::after {
  border-color: rgba(122, 171, 89, 0.84);
}

.number-card.is-dimmed {
  opacity: 0.68;
  filter: saturate(0.8);
}

.number-card.is-dimmed:hover:not([disabled]) {
  opacity: 0.9;
}

.number-card.is-result {
  background: var(--card-result-background);
}

.number-card:disabled {
  cursor: default;
}

.card-value {
  text-align: center;
  line-height: 1;
  font-weight: 800;
  letter-spacing: -0.04em;
  font-size: clamp(2.7rem, 5.6vw, 4.5rem);
}

.card-value.is-compact {
  font-size: clamp(2rem, 4vw, 3rem);
}

.operator-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

.operator-button {
  width: clamp(56px, 7vw, 70px);
  height: clamp(56px, 7vw, 70px);
  position: relative;
  border-radius: 999px;
  color: #11161c;
  font-size: clamp(1.6rem, 2.4vw, 2rem);
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
  transition: transform 180ms ease, opacity 180ms ease, box-shadow 180ms ease, filter 180ms ease;
}

.operator-button::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 999px;
  border: 2px solid transparent;
  opacity: 0;
  transition: opacity 180ms ease, border-color 180ms ease;
}

.operator-button:hover:not([disabled]) {
  transform: translateY(-1px) scale(1.02);
  filter: brightness(1.03);
}

.operator-button.is-selected {
  box-shadow:
    0 0 0 4px rgba(255, 255, 255, 0.2),
    0 0 0 10px rgba(125, 216, 255, 0.14),
    0 14px 28px rgba(0, 0, 0, 0.24);
  transform: translateY(-1px) scale(1.09);
  color: #ffffff;
  filter: saturate(1.06);
}

.operator-button.is-selected::after {
  opacity: 1;
  border-color: rgba(255, 255, 255, 0.88);
}

.operator-button.is-dimmed {
  opacity: 0.56;
}

.operator-button[disabled] {
  cursor: not-allowed;
  opacity: 0.42;
}

.operator-button[data-op="+"] {
  background: var(--add);
}

.operator-button[data-op="-"] {
  background: var(--subtract);
}

.operator-button[data-op="×"] {
  background: var(--multiply);
}

.operator-button[data-op="÷"] {
  background: var(--divide);
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0;
}

.action-button {
  min-width: 138px;
  padding: 12px 16px;
  border-radius: 18px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition:
    transform 180ms ease,
    background 180ms ease,
    border-color 180ms ease,
    opacity 180ms ease;
}

.action-button .control-icon {
  width: 18px;
  height: 18px;
  display: block;
  overflow: visible;
}

.action-button:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.11);
}

.action-button--primary {
  background: linear-gradient(135deg, rgba(125, 216, 255, 0.24), rgba(125, 216, 255, 0.12));
  border-color: rgba(125, 216, 255, 0.24);
}

:root[data-theme="light"] .action-button {
  background: rgba(238, 250, 231, 0.38);
  border-color: rgba(103, 139, 88, 0.2);
}

:root[data-theme="light"] .action-button:hover {
  background: rgba(247, 255, 239, 0.54);
  border-color: rgba(99, 148, 83, 0.28);
}

:root[data-theme="light"] .action-button--primary {
  background: linear-gradient(135deg, rgba(154, 202, 116, 0.2), rgba(235, 209, 121, 0.1));
  border-color: rgba(123, 167, 91, 0.28);
}

@media (max-width: 980px) {
  .app-shell {
    align-items: center;
  }

  .game-shell {
    height: min(100%, 860px);
    max-height: calc(100svh - var(--overlay-safe-top) - var(--overlay-safe-bottom));
  }
}

@media (min-width: 721px) and (max-width: 1100px) and (orientation: portrait) {
  .app-shell {
    min-height: var(--visible-viewport-height);
    padding-top: calc(70px + var(--safe-area-top));
    padding-bottom: 24px;
    align-items: flex-start;
  }

  .game-shell {
    width: min(100%, 820px);
    height: min(900px, calc(var(--visible-viewport-height) - 94px - var(--safe-area-top)));
    max-height: none;
    gap: 14px;
  }

  .hero {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .hero-meta {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .play-stage {
    width: min(100%, 620px);
    gap: 14px;
  }

  .board-wrap {
    width: 100%;
  }

  .board-grid {
    width: min(100%, min(500px, 48vh));
  }

  .control-dock {
    width: min(100%, 500px);
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.035);
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
  }

  .action-button {
    min-height: 48px;
  }
}

@media (max-width: 1366px) {
  .site-footer {
    position: static;
    transform: none;
    width: fit-content;
    display: flex;
    margin: 12px auto;
    padding: 0 12px calc(8px + var(--safe-area-bottom));
  }

  .seo-content {
    padding-bottom: 12px;
  }
}

@media (min-width: 721px) and (max-width: 1366px) and (orientation: landscape),
  (min-width: 1367px) and (orientation: landscape) and (max-height: 840px) {
  .app-shell {
    min-height: var(--visible-viewport-height);
    padding:
      calc(64px + var(--safe-area-top))
      calc(18px + var(--safe-area-right))
      calc(16px + var(--safe-area-bottom))
      calc(18px + var(--safe-area-left));
  }

  .game-shell {
    width: min(100%, 960px);
    height: auto;
    max-height: calc(var(--visible-viewport-height) - 80px - var(--safe-area-top) - var(--safe-area-bottom));
    padding: clamp(14px, 2.4vh, 20px) clamp(18px, 2.4vw, 26px);
    border-radius: 30px;
    gap: clamp(10px, 1.8vh, 14px);
  }

  .hero {
    align-items: center;
    gap: 16px;
  }

  .hero h1 {
    font-size: clamp(2rem, 3.2vw, 2.7rem);
    white-space: nowrap;
  }

  .hero__subtitle {
    margin-top: 0.25rem;
    font-size: 0.88rem;
  }

  .hero-meta {
    gap: 8px;
  }

  .hero-button,
  .hero-chip {
    min-width: 0;
    height: 44px;
    padding: 0 12px;
    border-radius: 16px;
  }

  .hero-chip__label,
  .hero-chip__value,
  .hero-chip__best,
  .control-label {
    font-size: 0.9rem;
  }

  .play-stage {
    width: min(100%, 590px);
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: minmax(0, 1fr);
    align-items: center;
    justify-items: center;
    gap: clamp(22px, 3vw, 32px);
  }

  .board-wrap {
    width: 100%;
  }

  .board-grid {
    width: min(100%, min(400px, calc(var(--visible-viewport-height) - 200px)));
    gap: clamp(10px, 1.8vh, 14px);
  }

  .number-card,
  .slot-ghost {
    min-height: 0;
    border-radius: clamp(20px, 3vh, 26px);
  }

  .control-dock {
    align-self: stretch;
    width: 118px;
    min-height: 100%;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 26px;
    background: rgba(255, 255, 255, 0.035);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 12px;
    overflow: visible;
  }

  .operator-row {
    display: grid;
    grid-template-columns: 66px;
    gap: 9px;
  }

  .operator-button {
    width: 66px;
    height: 66px;
    font-size: 1.8rem;
  }

  .action-row {
    width: 100%;
    margin-top: auto;
  }

  .action-button {
    width: 100%;
    min-width: 0;
    min-height: 44px;
    padding: 10px 6px;
    gap: 5px;
  }

  .seo-content {
    padding-top: 4px;
  }
}

@media (max-width: 720px) {
  :root {
    --overlay-safe-top: 54px;
    --overlay-safe-bottom: 42px;
  }

  .app-shell {
    padding:
      var(--overlay-safe-top)
      12px
      var(--overlay-safe-bottom);
  }

  .game-shell {
    padding: 14px;
    border-radius: 28px;
  }

  .hero {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .hero h1 {
    font-size: 1.95rem;
  }

  .hero__subtitle {
    margin-top: 0.22rem;
    font-size: 0.82rem;
  }

  .hero-meta {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    align-items: stretch;
  }

  .hero-chip {
    min-width: 0;
    height: 52px;
    padding: 0 12px;
    border-radius: 16px;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }

  .hero-button {
    min-width: 0;
    min-height: 52px;
    height: 52px;
    padding: 0 10px;
    border-radius: 16px;
    gap: 6px;
    font-size: 0.92rem;
  }

  .hero-chip__metrics {
    min-width: 0;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
  }

  .hero-chip__label {
    min-width: 0;
    justify-content: flex-start;
    gap: 5px;
    font-size: 0.92rem;
    white-space: nowrap;
  }

  .hero-chip__value {
    font-size: 0.92rem;
  }

  .hero-chip__best {
    font-size: 0.92rem;
  }

  .control-label {
    font-size: 0.92rem;
  }

  .control-icon {
    width: 14px;
    height: 14px;
  }

  .control-icon--chip {
    width: 12px;
    height: 12px;
  }

  .play-stage {
    gap: 14px;
  }

  .board-wrap {
    gap: 14px;
  }

  .board-grid {
    width: min(100%, 282px);
    gap: 12px;
  }

  .number-card,
  .slot-ghost {
    min-height: 84px;
    border-radius: 20px;
  }

  .card-value {
    font-size: clamp(2.4rem, 12vw, 3.5rem);
  }

  .operator-row {
    gap: 10px;
  }

  .operator-button {
    width: 52px;
    height: 52px;
    font-size: 1.55rem;
  }

  .action-button {
    flex: 1 1 0;
    min-width: 0;
    padding: 9px 12px;
  }

  .site-brand-link {
    top: calc(10px + var(--safe-area-top));
    left: calc(10px + var(--safe-area-left));
    width: 72px;
  }

  .site-footer {
    bottom: 6px;
    gap: 4px;
    font-size: 0.76rem;
    max-width: calc(100vw - 16px);
    padding: 0 8px;
  }

  .hero-button--theme .control-label {
    min-width: 0;
  }

  .seo-content {
    padding-bottom: calc(66px + var(--safe-area-bottom));
  }

  .about-game {
    border-radius: 22px;
  }

  .about-game__summary {
    padding: 11px 14px;
    font-size: 0.92rem;
  }

}

@media (max-width: 405px) {
  .hero-chip {
    padding: 0 11px;
  }

  .hero-chip__label {
    font-size: 0.92rem;
  }

  .hero-chip__best {
    display: none;
  }
}

@media (max-height: 840px) {
  .app-shell {
    min-height: calc(100svh - 138px - var(--safe-area-bottom));
  }

  .seo-content {
    padding-bottom: calc(44px + var(--safe-area-bottom));
  }

  .game-shell {
    gap: 14px;
  }

  .play-stage {
    gap: 14px;
  }

  .board-grid {
    width: min(100%, min(360px, 42vh));
    gap: 12px;
  }

  .number-card,
  .slot-ghost {
    min-height: 84px;
  }

  .site-brand-link {
    width: clamp(84px, 7vw, 110px);
  }

  .site-footer {
    bottom: 6px;
    font-size: 0.82rem;
  }
}

@media (min-width: 721px) and (max-width: 1366px) and (orientation: landscape),
  (min-width: 1367px) and (orientation: landscape) and (max-height: 840px) {
  .app-shell {
    min-height: var(--visible-viewport-height);
  }

  .board-grid {
    width: min(100%, min(400px, calc(var(--visible-viewport-height) - 200px)));
  }

  .number-card,
  .slot-ghost {
    min-height: 0;
  }
}
