/*
 * reversi001.css
 * Ownership: shared shell, title screen, simple Reversi, shared board primitives,
 * and developer controls.
 * Wakabattle dialogs, cut-ins, results, and responsive presentation belong in reversi002.css.
 */

#reversi *,
#reversi *::before,
#reversi *::after {
  box-sizing: border-box;
}

#reversi *,
#reversi *:focus,
#reversi *:active,
#reversi button,
#reversi button:focus,
#reversi button:active {
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  outline: none;
}

#reversi {
  font-family: "Baloo 2", sans-serif;
  background: #f5f5f5;
  min-height: 100vh;
  overflow-x: hidden;
  overflow-y: auto;
  position: relative;
}
#reversi::before {
  content: "";
  position: absolute;
  inset: 0;
  min-height: 100%;
  background: url("https://wakabaland.com/wp-content/uploads/2026/10/E001-reversi-screen-001.webp")
    center center / cover no-repeat;
  opacity: 0.18;
  z-index: 0;
  pointer-events: none;
}
@media (max-width: 480px) {
  #reversi::before {
    background-image: url("https://wakabaland.com/wp-content/uploads/2026/10/E001-reversi-screen-002.webp");
  }
}

.screen {
  display: none;
  width: 100%;
  min-height: 100vh;
}
.screen.active {
  display: flex;
  position: relative;
  z-index: 1;
}

/* 開発用表示テスト。通常時は一つのボタンだけを最下段に置く。 */
#sb-test-bar {
  position: relative;
  z-index: 50000;
  display: flex;
  align-self: center;
  justify-content: center;
  width: min(100%, 560px);
  margin: 6px auto 0;
  pointer-events: auto;
  font-family: "DotGothic16", sans-serif;
}

/* テスト操作は残すが、対局中のスキル発動ボタンより前に出さない。 */
#reversi .sb-bottom-ability-col {
  z-index: 2;
}
#reversi .sb-player-activate-row {
  z-index: 2;
}

.sb-test-launcher,
.sb-test-menu button,
.sb-test-menu select {
  position: relative;
  z-index: 50001;
  font-family: "DotGothic16", sans-serif;
  font-size: var(--wk-font-control, 16px);
  line-height: 1;
  pointer-events: auto;
  touch-action: manipulation;
}

.sb-test-launcher {
  min-width: 112px;
  min-height: 36px;
  padding: 8px 20px;
  border: 2px solid #e8dcff;
  border-radius: 8px;
  background: linear-gradient(180deg, #8c4edf, #5820a3);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  box-shadow:
    0 3px 0 #351065,
    0 5px 12px rgba(22, 7, 45, 0.38);
}

.sb-test-launcher::after {
  content: "▲";
  display: inline-block;
  margin-left: 8px;
  font-size: var(--wk-font-min, 14px);
  transition: transform 0.18s ease;
}

#sb-test-bar.is-open .sb-test-launcher::after {
  transform: rotate(180deg);
}

.sb-test-menu[hidden] {
  display: none !important;
}

.sb-test-menu {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  z-index: 50002;
  width: min(540px, calc(100vw - 18px));
  max-height: min(70vh, 560px);
  padding: 12px;
  border: 2px solid rgba(218, 203, 255, 0.92);
  border-radius: 8px;
  background: rgba(18, 15, 30, 0.97);
  color: #fff;
  overflow-y: auto;
  transform: translateX(-50%);
  box-shadow:
    0 14px 32px rgba(0, 0, 0, 0.5),
    inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.sb-test-menu-title {
  margin: 0 0 10px;
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  text-align: center;
}

.sb-test-group {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.sb-test-group-title {
  color: #e9e3f5;
  font-size: var(--wk-font-min, 14px);
  font-weight: 700;
  text-align: left;
}

.sb-test-grid,
.sb-test-status-row,
.sb-test-cutin-row,
.sb-test-board-row {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.sb-test-grid-four {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.sb-test-grid-three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.sb-test-grid-two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.sb-test-status-row {
  grid-template-columns: minmax(0, 1fr) 88px;
}
.sb-test-cutin-row {
  grid-template-columns: minmax(0, 1fr) 70px 70px;
}
.sb-test-board-row {
  grid-template-columns: minmax(0, 1fr) 88px;
}

.sb-test-menu button,
.sb-test-menu select {
  width: 100%;
  min-width: 0;
  min-height: 34px;
  padding: 7px 8px;
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 5px;
  background: #353044;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.42);
}

.sb-test-menu button:hover,
.sb-test-menu button:focus-visible,
.sb-test-menu select:focus-visible {
  filter: brightness(1.18);
  border-color: #fff;
}

.sb-test-group-clear button {
  background: #157a4c;
}
.sb-test-group-start button {
  background: #176fb0;
}
.sb-test-group-status button {
  background: #7542bc;
}
.sb-test-group-cutin button {
  background: #8b3fb5;
}
.sb-test-group-board-effect button {
  background: #a55d19;
}
.sb-test-group-endroll button {
  background: #242127;
}
.sb-test-group-result button[data-sb-test="win"] {
  background: #287252;
}
.sb-test-group-result button[data-sb-test="draw"] {
  background: #55515b;
}
.sb-test-group-result button[data-sb-test="lose"] {
  background: #a63b35;
}

@media (max-width: 560px) {
  .sb-test-menu {
    position: absolute;
    inset: auto auto calc(100% + 8px) 50%;
    width: calc(100vw - 18px);
    max-height: calc(100vh - 72px);
    padding: 5px 7px;
    transform: translateX(-50%);
  }
  .sb-test-menu-title {
    margin-bottom: 2px;
    font-size: 14px;
  }
  .sb-test-group {
    grid-template-columns: 1fr;
    gap: 2px;
    padding: 2px 4px;
  }
  .sb-test-group-title {
    font-size: var(--wk-font-min, 14px);
    text-align: center;
  }
  .sb-test-menu button,
  .sb-test-menu select {
    min-height: 24px;
    padding: 3px 5px;
    font-size: var(--wk-font-control, 16px);
  }
}

#screen-title {
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  position: relative;
  overflow: hidden;
  padding: 200px 16px 40px;
}

@media (min-width: 769px) and (max-height: 820px) {
  #screen-title.bg-magic {
    padding-top: clamp(88px, 14vh, 112px);
    padding-bottom: 24px;
  }

  #screen-title.bg-magic .title-logo-area {
    height: clamp(64px, 10vh, 80px);
    margin-bottom: clamp(12px, 2.5vh, 18px);
  }
}

@media (max-width: 767px) {
  #reversi {
    min-height: auto;
  }
  #screen-title.screen {
    min-height: auto;
  }

  #screen-title {
    height: auto;
    padding: 140px 20px 0;
    justify-content: flex-start;
    align-items: center;
  }

  #screen-title .title-logo-area {
    height: 84px;
    margin-bottom: 32px;
  }
  #screen-title .title-discs {
    margin-bottom: 6px;
  }

  #screen-title .title-content {
    max-width: 380px;
    width: 100%;
    padding-bottom: 48px;
  }

  #screen-title .mode-section {
    gap: 8px;
    width: 100%;
  }
  #screen-title .mode-cards {
    gap: 8px;
    width: 100%;
  }
  #screen-title .mode-card {
    border-radius: 4px;
    padding: 12px 16px;
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "sound" "heading" "description" "start" "records";
  }
  #screen-title .mode-card.simple {
    grid-template-areas: "sound" "heading" "description" "start";
  }
  #screen-title .mode-card .mode-name {
    text-align: center;
  }
}

#screen-title::before {
  content: "";
  position: absolute;
  inset: 0;
  background-color: #f6f7f9;
  background-image:
    linear-gradient(rgba(0, 0, 0, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 0, 0, 0.07) 1px, transparent 1px);
  background-size: 28px 28px;
  z-index: 0;
  pointer-events: none;
}

.title-content {
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 460px;
  padding: 0 4px;
}

.title-logo-area {
  position: relative;
  height: 128px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 80px;
}
.title-logo-default {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.title-discs {
  display: flex;
  gap: 14px;
  margin-bottom: 16px;
}
.title-disc {
  width: clamp(40px, 10vw, 56px);
  height: clamp(40px, 10vw, 56px);
  border-radius: 50%;
  box-shadow:
    0 6px 0 rgba(0, 0, 0, 0.15),
    inset 0 3px 10px rgba(255, 255, 255, 0.3),
    0 0 20px rgba(0, 0, 0, 0.1);
}
.title-disc.black {
  background: radial-gradient(circle at 36% 32%, #555, #111);
}
.title-disc.white {
  background: radial-gradient(circle at 36% 32%, #fff, #e0e0e0);
  border: 1px solid #ddd;
}
.title-main {
  font-family: "Cinzel Decorative", serif;
  font-size: clamp(22px, 6vw, 44px);
  font-weight: 900;
  color: #111;
  text-align: center;
  line-height: 1.1;
  letter-spacing: 0.04em;
  text-shadow: none;
}

.mode-section {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.mode-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}
.mode-card {
  position: relative;
  background: #fff;
  border: 2px solid #000;
  border-radius: 4px;
  padding: clamp(12px, 3vw, 18px) clamp(14px, 4vw, 22px);
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "heading sound" "description description" "start start" "records records";
  align-items: stretch;
  gap: 12px;
  overflow: hidden;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.mode-card::before {
  content: none;
}
.mode-card:not(.disabled):hover {
  border-color: #000;
}
.mode-card:not(.disabled):active {
  transform: none;
}
.mode-card.simple {
  grid-template-areas: "heading sound" "description description" "start start";
}

.mode-card.disabled {
  cursor: not-allowed;
  opacity: 0.5;
  filter: saturate(0.4);
}

.mode-text {
  display: contents;
}
.mode-card .mode-name {
  grid-area: heading;
  align-self: center;
  margin: 0;
  min-width: 0;
  text-wrap: balance;
}
.mode-card .mode-desc {
  grid-area: description;
  text-align: center;
  word-break: auto-phrase;
  text-wrap: balance;
}
.mode-card .mode-select-btn {
  position: relative;
  z-index: 1;
}
.mode-start-controls {
  grid-area: start;
  justify-self: center;
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: min(320px, 100%);
  flex-shrink: 0;
  gap: 8px;
}
#reversi .title-sound-btn {
  appearance: none;
  position: relative;
  grid-area: sound;
  align-self: start;
  justify-self: end;
  z-index: 1;
  min-width: 92px;
  min-height: 44px;
  padding: 8px 12px;
  border: 2px solid #111;
  border-radius: 4px;
  background: #111;
  color: #fff;
  font-family: "Baloo 2", sans-serif;
  font-size: var(--wk-font-control, 18px);
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: none;
  text-shadow: none;
  animation: none;
}
#reversi .title-sound-btn.is-on {
  background: #333;
}
#reversi .mode-card.magic .title-sound-btn {
  border-color: #fff;
  background: #111;
  color: #fff;
  font-family: "DotGothic16", "Baloo 2", sans-serif;
}
#reversi .mode-card.magic .title-sound-btn.is-on {
  background: #fff;
  color: #111;
}
#reversi .title-sound-btn:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 3px;
}
.mode-name {
  font-family: "Fredoka One", sans-serif;
  font-size: clamp(16px, 4vw, 20px);
  font-weight: 700;
  color: #111;
  letter-spacing: 0.04em;
  margin-bottom: 2px;
}
.mode-desc {
  font-size: var(--wk-font-body, 16px);
  font-weight: 500;
  color: #000;
  letter-spacing: 0.03em;
  line-height: 1.5;
  word-break: auto-phrase;
  text-wrap: balance;
}

.mode-badge {
  font-family: "Fredoka One", sans-serif;
  font-size: var(--wk-font-meta, 14px);
  padding: 3px 10px;
  border-radius: 20px;
  letter-spacing: 0.08em;
  flex-shrink: 0;
}
.mode-card.simple .mode-badge {
  background: rgba(0, 0, 0, 0.05);
  color: #444;
  border: 1px solid rgba(0, 0, 0, 0.12);
}
.mode-card.magic .mode-badge {
  background: rgba(0, 0, 0, 0.7);
  color: #eee;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.magic-sub-btns {
  display: flex;
  flex-direction: row;
  justify-content: center;
  gap: 0;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition:
    max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.25s,
    gap 0.3s;
  pointer-events: none;
}
.magic-sub-btns.open {
  max-height: 70px;
  opacity: 1;
  gap: 8px;
  padding-top: 8px;
  pointer-events: auto;
}
.magic-sub-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex: 0 1 140px;
  padding: 9px 16px;
  border-radius: 12px;
  border: 1.5px solid #ddd;
  background: #f5f5f5;
  color: #333;
  font-family: "Fredoka One", sans-serif;
  font-size: var(--wk-font-control, 18px);
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  white-space: nowrap;
}
.magic-sub-btn:hover {
  background: #eee;
  border-color: #bbb;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  color: #111;
  transform: translateY(-2px) scale(1.04);
}
.magic-sub-btn:active {
  transform: scale(0.97);
}
.magic-sub-btn.new-btn {
  background: #f5f5f5;
  border-color: #ddd;
  color: #333;
}
.magic-sub-btn.new-btn:hover {
  background: #eee;
  border-color: #bbb;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  color: #111;
  transform: translateY(-2px) scale(1.04);
}
.magic-sub-btn.resume-btn {
  background: #111;
  border-color: #333;
  color: #fff;
}
.magic-sub-btn.resume-btn:hover {
  background: #333;
  border-color: #555;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  color: #fff;
  transform: translateY(-2px) scale(1.04);
}
.sub-btn-icon {
  font-size: 18px;
}
.sub-btn-label {
  font-size: var(--wk-font-control, 18px);
}

#screen-game {
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  background: #f5f5f5;
  padding: 16px;
  position: relative;
  overflow-y: auto;
  overflow-x: hidden;
}

.reversi-game {
  --ot-board: #3a8a5a;
  --ot-accent: #444444;
  --ot-accent2: #222222;
  --ot-text: #111111;
  --ot-dim: #888888;

  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  font-family: "Baloo 2", "Arial Rounded MT Bold", sans-serif;
  font-weight: 800;
  color: var(--ot-text);
  margin: 0 auto;
}

.reversi-game .ot-card {
  background: #fff;
  border: 1.5px solid #e0e0e0;
  border-radius: 22px;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.8) inset,
    0 4px 0 rgba(0, 0, 0, 0.04),
    0 8px 24px rgba(0, 0, 0, 0.06);
  padding: 10px 12px;
  position: relative;
  overflow: clip;
}

.reversi-game .ot-card::before {
  content: "";
  position: absolute;
  top: 4px;
  left: 8px;
  right: 8px;
  height: 38%;
  border-radius: 14px 14px 50% 50%;
  background: rgba(255, 255, 255, 0.25);
  pointer-events: none;
  z-index: 0;
}

.reversi-game .ot-card > * {
  position: relative;
  z-index: 1;
}

.reversi-game .ot-score-panel {
  display: flex;
  align-items: stretch;
  gap: 6px;
  flex-wrap: wrap;
  position: relative;
  z-index: 1;
}
.reversi-game .ot-score-side {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 8px 4px;
  border-radius: 14px;
  transition: all 0.25s;
  position: relative;
  min-width: 80px;
}

.reversi-game .ot-score-side.active {
  background: rgba(0, 0, 0, 0.05);
  box-shadow: 0 0 0 2.5px #333;
}
.reversi-game .ot-score-side.active::after {
  content: none;
}

.reversi-game .ot-score-side.cpu-active {
  background: rgba(0, 0, 0, 0.04);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.2);
}
.reversi-game .ot-score-side.cpu-active::after {
  content: none;
}

.reversi-game .ot-disc-icon {
  width: clamp(28px, 7vw, 36px);
  height: clamp(28px, 7vw, 36px);
  border-radius: 50%;
  box-shadow:
    0 3px 0 rgba(0, 0, 0, 0.15),
    inset 0 -2px 4px rgba(0, 0, 0, 0.1),
    inset 0 2px 6px rgba(255, 255, 255, 0.3);
  flex-shrink: 0;
}
.reversi-game .ot-disc-icon.black {
  background: radial-gradient(circle at 38% 35%, #555, #111);
}
.reversi-game .ot-disc-icon.white {
  background: radial-gradient(circle at 38% 35%, #fff, #e0e0e0);
  border: 1px solid #ddd;
}

.reversi-game .ot-score-label {
  font-size: max(var(--wk-font-min, 14px), clamp(11px, 2.8vw, 14px));
  letter-spacing: 0.08em;
  color: rgba(0, 0, 0, 0.85);
  font-weight: 700;
  white-space: nowrap;
}
.reversi-game .ot-score-num {
  font-family: "Fredoka One", sans-serif;
  font-size: clamp(36px, 9vw, 46px);
  color: #111;
  text-shadow: none;
  line-height: 1;
}

.reversi-game .ot-vs-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  align-self: stretch;
  position: relative;
  z-index: 1;
}

.reversi-game .ot-message-row {
  width: 100%;
  flex-basis: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 2px;
  min-height: 32px;
  flex-shrink: 0;
}
.reversi-game .ot-message-row .ot-message {
  flex: 1;
  width: auto;
  flex-basis: auto;
  text-align: center;
  padding-top: 0;
  min-height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

@media (min-width: 481px) {
  .reversi-game .ot-card.ot-score-panel {
    padding-bottom: 0;
    overflow: visible;
  }
  .reversi-game .ot-message-row {
    margin-left: -12px;
    margin-right: -12px;
    margin-bottom: -10px;
    width: calc(100% + 24px);
    flex-basis: calc(100% + 24px);
    padding: 6px 0 10px;
    border-radius: 0 0 20px 20px;
    min-height: 40px;
  }
  .reversi-game .ot-message-row .ot-message {
    padding-top: 0;
    min-height: 24px;
  }
}

.reversi-game .ot-vs {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Fredoka One", sans-serif;
  font-size: clamp(22px, 5.5vw, 30px);
  color: #444;
  letter-spacing: 0.08em;
  flex-shrink: 0;
  align-self: center;
}

.reversi-game .ot-message {
  width: 100%;
  flex-basis: 100%;
  text-align: center;
  font-size: var(--wk-font-body, 16px);
  letter-spacing: 0.1em;
  color: rgba(0, 0, 0, 0.8);
  padding-top: 2px;
  min-height: 20px;
  display: block;
  white-space: pre;
}

.reversi-game .ot-board-wrap {
  padding: 14px;
  position: relative;
}
.ability-battle .ot-board-wrap {
  width: 100%;
  box-sizing: border-box;
  align-self: stretch;
}
.reversi-game .ot-board-inner {
  background: #234f18;
  border-radius: 14px;
  padding: 0;
  overflow: hidden;
  box-shadow:
    0 0 0 3px rgba(20, 70, 10, 0.6),
    0 6px 0 rgba(10, 45, 5, 0.5),
    0 10px 24px rgba(10, 45, 5, 0.3);
  position: relative;
}
.reversi-game .ot-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  padding: 2px;
  background: #145c30;
}
.ability-battle .ot-board-inner,
.ability-battle .ot-grid {
  width: 100%;
  box-sizing: border-box;
}
.reversi-game .ot-cell {
  aspect-ratio: 1;
  background: #2f7a4e;
  border-radius: 0;
  position: relative;
  cursor: pointer;
  transition: background 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.reversi-game .ot-cell.combo-on-top,
.ability-battle .ot-cell.combo-on-top,
.reversi-game .ot-cell.fx-target-top,
.ability-battle .ot-cell.fx-target-top {
  z-index: 2;
  isolation: isolate;
}

.combo-board-active.ot-grid {
  background: #b89600 !important;
}
.combo-board-active .ot-cell {
  background: #d4bc30 !important;
  transition: none !important;
}
.combo-board-active .ot-cell:hover {
  background: #dfc840 !important;
}
.combo-board-active .ot-cell.combo-on-top .ot-disc {
  background: radial-gradient(
    circle at 36% 32%,
    #fff9b0,
    #f0c800,
    #c08000
  ) !important;
  box-shadow:
    0 3px 0 rgba(0, 0, 0, 0.28),
    0 0 20px 8px rgba(255, 210, 0, 0.8),
    inset 0 -2px 5px rgba(0, 0, 0, 0.1),
    inset 0 3px 8px rgba(255, 255, 255, 0.5) !important;
}

.reversi-game .placement-board-active.ot-grid,
.ability-battle .placement-board-active.ot-grid,
.placement-board-active.ot-grid {
  background: #0a4060 !important;
}
.reversi-game .placement-board-active .ot-cell,
.ability-battle .placement-board-active .ot-cell,
.placement-board-active .ot-cell {
  transition: none !important;
}

.reversi-game .flip-board-active.ot-grid,
.ability-battle .flip-board-active.ot-grid,
.flip-board-active.ot-grid {
  background: #1a0030 !important;
}
.reversi-game .flip-board-active .ot-cell,
.ability-battle .flip-board-active .ot-cell,
.flip-board-active .ot-cell {
  transition: none !important;
}

.reversi-game .erase-board-active.ot-grid,
.ability-battle .erase-board-active.ot-grid,
.erase-board-active.ot-grid {
  background: #cc3300 !important;
}
.reversi-game .erase-board-active .ot-cell,
.ability-battle .erase-board-active .ot-cell,
.erase-board-active .ot-cell {
  transition: none !important;
}

.reversi-game .block-board-active.ot-grid,
.ability-battle .block-board-active.ot-grid,
.block-board-active.ot-grid {
  background: #3a1800 !important;
}
.reversi-game .block-board-active .ot-cell,
.ability-battle .block-board-active .ot-cell,
.block-board-active .ot-cell {
  transition: none !important;
}

.reversi-game .ot-cell:hover {
  background: #3a8f5c;
}

.ability-battle .ot-grid {
  gap: 2px;
  padding: 2px;
  background: #0d4327;
}
.ability-battle .ot-cell {
  background: #2f8151;
  box-shadow:
    1px 1px 0 rgba(123, 196, 145, 0.22) inset,
    -1px -1px 0 rgba(3, 38, 20, 0.22) inset;
  transition: background-color 80ms steps(2, end);
}
.ability-battle .ot-cell.hint:not(.hint-guided) {
  background: rgba(255, 255, 255, 0.14) !important;
  outline: 2.5px solid rgba(255, 255, 255, 0.9);
  outline-offset: -2px;
  border-radius: 2px;
  animation: normal-hint-glow 1.2s ease-in-out infinite;
  z-index: 1;
}
.ability-battle .ot-cell.hint:not(.hint-guided):hover {
  background: rgba(255, 255, 255, 0.32) !important;
  outline-color: rgba(255, 255, 255, 1);
  box-shadow: 0 0 14px 5px rgba(255, 255, 255, 0.6);
  animation: none;
}

.reversi-game .ot-cell.hint {
  background: rgba(255, 255, 255, 0.14);
  outline: 2.5px solid rgba(255, 255, 255, 0.9);
  outline-offset: -2px;
  border-radius: 2px;
  animation: normal-hint-glow 1.2s ease-in-out infinite;
  z-index: 1;
}
.reversi-game .ot-cell.hint::after {
  content: none;
}
.reversi-game .ot-cell.hint:hover {
  background: rgba(255, 255, 255, 0.3);
  outline-color: rgba(255, 255, 255, 1);
  box-shadow: 0 0 14px 5px rgba(255, 255, 255, 0.55);
  animation: none;
}

@keyframes normal-hint-glow {
  0%,
  100% {
    outline-color: rgba(255, 255, 255, 0.55);
    background: rgba(255, 255, 255, 0.07);
    box-shadow: 0 0 5px 1px rgba(255, 255, 255, 0.2);
  }
  50% {
    outline-color: rgba(255, 255, 255, 1);
    background: rgba(255, 255, 255, 0.22);
    box-shadow: 0 0 14px 5px rgba(255, 255, 255, 0.55);
  }
}

.reversi-game .ot-disc {
  width: 82%;
  height: 82%;
  border-radius: 50%;
  position: absolute;
  animation: ot-drop 0.18s cubic-bezier(0.3, 1.5, 0.6, 1);
  box-shadow:
    0 4px 0 rgba(0, 0, 0, 0.45),
    0 5px 10px rgba(0, 0, 0, 0.35),
    inset 0 -3px 6px rgba(0, 0, 0, 0.2),
    inset 0 3px 10px rgba(255, 255, 255, 0.18);
}
.reversi-game .ot-disc.black {
  background: radial-gradient(
    circle at 34% 28%,
    #888 0%,
    #444 22%,
    #1a1a1a 55%,
    #111 100%
  );
}
.reversi-game .ot-disc.white {
  background: radial-gradient(
    circle at 34% 28%,
    #ffffff 0%,
    #f8f8f8 35%,
    #e0e0e0 70%,
    #c8c8c8 100%
  );
  box-shadow:
    0 4px 0 rgba(0, 0, 0, 0.25),
    0 5px 10px rgba(0, 0, 0, 0.2),
    inset 0 -3px 6px rgba(0, 0, 0, 0.08),
    inset 0 3px 10px rgba(255, 255, 255, 0.9);
}
.reversi-game .ot-disc.flip {
  animation: ot-flip 0.32s ease;
}

@keyframes ot-drop {
  0% {
    transform: scale(0) translateY(-8px);
    opacity: 0.6;
  }
  80% {
    transform: scale(1.08);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}
@keyframes ot-flip {
  0% {
    transform: rotateY(0deg);
  }
  50% {
    transform: rotateY(90deg) scaleX(0.5);
  }
  100% {
    transform: rotateY(0deg);
  }
}

.reversi-game .ot-btn-row {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}
.reversi-game .ot-btn-row .ot-btn {
  flex: 0 1 auto;
  min-width: 0;
  white-space: nowrap;
  font-size: var(--wk-font-control, 18px);
  padding: 8px 16px;
}
#reversi .ot-btn,
.reversi-game .ot-btn {
  appearance: none;
  -webkit-appearance: none;
  box-sizing: border-box;
  min-width: min(230px, 75vw);
  min-height: 44px;
  padding: 9px 24px 11px;
  border: 1.5px solid rgba(255, 255, 255, 0.18);
  border-bottom-width: 4px;
  border-radius: 999px;
  background: var(--rv-button-bg, var(--wk-button-confirm));
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: "DotGothic16", sans-serif;
  font-size: max(var(--wk-font-control, 16px), clamp(14px, 3.8vw, 18px));
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0;
  text-align: center;
  white-space: nowrap;
  box-shadow:
    0 4px 0 rgba(42, 22, 10, 0.82),
    0 2px 0 rgba(255, 255, 255, 0.14) inset,
    0 8px 18px rgba(0, 0, 0, 0.24);
  transition: all 0.18s;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.34);
  outline: none;
  animation: none;
}
#reversi .ot-btn:hover,
.reversi-game .ot-btn:hover {
  background: var(--rv-button-hover, var(--wk-button-confirm-hover));
  transform: translateY(-1px);
}
#reversi .ot-btn:active,
.reversi-game .ot-btn:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 rgba(42, 22, 10, 0.82);
}

#reversi .ot-btn.secondary,
.reversi-game .ot-btn.secondary {
  border-color: var(--wk-button-neutral-edge);
  background: var(--wk-button-neutral);
  color: var(--wk-button-neutral-ink);
  box-shadow:
    0 2px 0 rgba(92, 58, 28, 0.34),
    0 1px 0 rgba(255, 255, 255, 0.52) inset,
    0 7px 16px rgba(0, 0, 0, 0.1);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.72);
}
#reversi .ot-btn.secondary:hover,
.reversi-game .ot-btn.secondary:hover {
  background: var(--wk-button-neutral-hover);
}

#reversi #ot-result-retry { --rv-button-bg: var(--wk-button-play); --rv-button-hover: var(--wk-button-play-hover); }
/* Simple Reversi owns its cards, setup controls, audio, and result presentation. */
#reversi-game-root.simple-reversi {
  gap: 10px;
  color: #172a23;
  font-weight: 600;
}

#reversi-game-root,
#reversi-game-root * {
  box-sizing: border-box;
  font-family: "Yu Gothic UI", "Yu Gothic", Meiryo, sans-serif;
}

#reversi-game-root .ot-card {
  padding: 12px;
  border: 1px solid #dce5df;
  border-radius: 14px;
  box-shadow: 0 4px 16px rgba(24, 53, 39, 0.06);
}
#reversi-game-root .ot-card::before {
  content: none;
}

.simple-audio-toolbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 44px;
}
.simple-bgm-toggle {
  box-sizing: border-box;
  min-width: 104px;
  min-height: 44px;
  padding: 9px 12px;
  border: 1px solid #999;
  border-radius: 10px;
  background: #fff;
  color: #111;
  font-size: var(--wk-font-control, 18px);
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.04em;
  box-shadow: none;
  cursor: pointer;
}
.simple-bgm-toggle.is-on {
  border-color: #171717;
  background: #171717;
  color: #fff;
}

#reversi-game-root .ot-score-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 24px minmax(0, 1fr);
  align-items: stretch;
  gap: 8px;
  overflow: hidden;
}
#reversi-game-root .ot-score-side {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  align-content: center;
  justify-items: start;
  column-gap: 10px;
  row-gap: 2px;
  padding: 8px;
  min-width: 0;
  border: 1px solid transparent;
  border-radius: 10px;
  background: #f6f8f6;
  box-shadow: none;
  transition:
    border-color 0.2s,
    background-color 0.2s;
}
#reversi-game-root .ot-score-side.active,
#reversi-game-root .ot-score-side.cpu-active {
  border-color: #33845d;
  background: #eaf5ee;
  box-shadow: inset 0 0 0 1px #33845d;
}
#reversi-game-root .ot-disc-icon {
  grid-row: 1 / 3;
  align-self: center;
  width: 32px;
  height: 32px;
}
#reversi-game-root .ot-score-label {
  align-self: end;
  font-size: var(--wk-font-meta, 14px);
  letter-spacing: 0;
  color: #34473c;
}
#reversi-game-root .ot-score-num {
  font-size: 32px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #15281e;
  line-height: 1.1;
}
#reversi-game-root .ot-vs {
  font-size: 14px;
  color: #8a9b90;
}
#reversi-game-root .ot-message-row {
  grid-column: 1 / -1;
  width: 100%;
  margin: 0;
  padding: 8px 4px 0;
  border-top: 1px solid #e5ebe6;
  border-radius: 0;
  min-height: 36px;
}
#reversi-game-root .ot-message-row .ot-message {
  min-height: 24px;
  font-size: var(--wk-font-body, 16px);
  line-height: 1.5;
  letter-spacing: 0;
  white-space: normal;
  overflow-wrap: anywhere;
  color: #42564a;
}

#reversi-game-root .ot-board-wrap {
  padding: 10px;
}
#reversi-game-root .ot-board-inner {
  background: #174d35;
  border: 2px solid #255b3f;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(19, 61, 39, 0.15);
}
#reversi-game-root .ot-grid {
  gap: 1px;
  padding: 1px;
  background: #1d573d;
}
#reversi-game-root .ot-cell {
  background: #31805a;
}
#reversi-game-root .ot-cell:hover {
  background: #398b62;
}

#reversi-game-root .simple-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
#reversi-game-root .ot-color-row,
#reversi-game-root .ot-difficulty {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  width: 100%;
}
#reversi-game-root .ot-diff-label {
  font-size: var(--wk-font-meta, 14px);
  font-weight: 600;
  letter-spacing: 0;
  color: #5c6d62;
}
#reversi-game-root .ot-diff-levels {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}
#reversi-game-root .ot-diff-levels--lv {
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 4px;
}
#reversi-game-root .ot-diff-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 0;
  width: 100%;
  height: 44px;
  padding: 0 4px;
  border: 1px solid #d6dfd8;
  border-radius: 8px;
  background: #f7f9f7;
  color: #34473c;
  font-size: var(--wk-font-control, 18px);
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition:
    border-color 0.15s,
    background-color 0.15s;
}
#reversi-game-root .ot-diff-btn:hover {
  border-color: #69977d;
  background: #edf4ee;
}
#reversi-game-root .ot-diff-btn.selected {
  border-color: #21583e;
  background: #21583e;
  color: #fff;
  box-shadow: none;
}
#reversi-game-root .ot-btn-disc {
  width: 12px;
  height: 12px;
  margin: 0;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}
#reversi-game-root .ot-btn-disc.black {
  background: radial-gradient(circle at 38% 35%, #555, #111);
}
#reversi-game-root .ot-btn-disc.white {
  background: radial-gradient(circle at 38% 35%, #fff, #ddd);
  border: 1px solid #ccc;
}
#reversi-game-root .ot-btn-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
  padding-top: 10px;
  border-top: 1px solid #e5ebe6;
}
#reversi #reversi-game-root .ot-btn {
  min-width: 0;
  min-height: 44px;
  width: 100%;
  padding: 10px 6px;
  border: 1px solid #171717;
  border-radius: 10px;
  background: var(--rv-button-bg, #171717);
  color: #fff;
  font-size: var(--wk-font-control, 18px);
  font-weight: 700;
  line-height: 1.2;
  text-shadow: none;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12);
  transition:
    background-color 0.15s,
    transform 0.15s;
}
#reversi #reversi-game-root .ot-btn:hover {
  background: var(--rv-button-hover, #383838);
  transform: none;
}
#reversi #reversi-game-root .ot-btn.secondary {
  border-color: #999;
  background: #fff;
  color: #111;
  box-shadow: none;
}
#reversi #reversi-game-root .ot-btn.secondary:hover {
  background: #f0f0f0;
}
#reversi #reversi-game-root .ot-btn:active {
  transform: translateY(1px);
}
#reversi #reversi-game-root button:focus-visible {
  outline: 3px solid #555;
  outline-offset: 2px;
}

#reversi-game-root #ot-result-overlay {
  position: absolute;
  inset: 0;
  padding: 20px;
  border-radius: 12px;
  background: rgba(10, 31, 21, 0.65);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 10;
}
#reversi-game-root .ot-result-dialog {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  width: min(100%, 320px);
  padding: 28px 20px;
  border: 1px solid #dce5df;
  border-radius: 16px;
  background: #fff;
  text-align: center;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.2);
}
#reversi-game-root .ot-result-title {
  margin: 0;
  font-size: 30px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.04em;
  color: #21583e;
  text-shadow: none;
}
#reversi-game-root #ot-result-overlay.result-lose .ot-result-title {
  color: #8b4740;
}
#reversi-game-root .ot-result-scores {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 24px;
  padding: 12px 24px;
  border: 1px solid #e1e8e2;
  border-radius: 12px;
  background: #f6f9f6;
}
#reversi-game-root .ot-result-num {
  font-size: 40px;
  font-weight: 700;
  color: #172a23;
  text-shadow: none;
  line-height: 1;
}
#reversi-game-root .ot-result-vs {
  color: #8a9b90;
}
#reversi-game-root .ot-result-sub {
  display: none;
}

@media (max-width: 480px) {
  #screen-game {
    padding: 12px;
  }
  #reversi-game-root .ot-score-panel {
    gap: 6px;
  }
  #reversi-game-root .ot-score-side {
    grid-template-columns: 26px minmax(0, 1fr);
    column-gap: 7px;
    padding: 7px;
  }
  #reversi-game-root .ot-disc-icon {
    width: 26px;
    height: 26px;
  }
  #reversi-game-root .ot-score-label {
    font-size: var(--wk-font-min, 14px);
  }
  #reversi-game-root .ot-difficulty {
    grid-template-columns: 1fr;
    gap: 6px;
  }
  #reversi-game-root .ot-diff-levels--lv {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
  #reversi-game-root .ot-diff-btn {
    font-size: var(--wk-font-control, 16px);
  }
  #reversi-game-root .ot-btn {
    font-size: var(--wk-font-control, 16px);
  }
  #reversi-game-root #ot-result-overlay {
    padding: 14px;
  }
  #reversi-game-root .ot-result-dialog {
    gap: 12px;
    padding: 22px 16px;
  }
  #reversi-game-root .ot-result-title {
    font-size: 26px;
  }
}

.reversi-game .ot-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 15, 0.85);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-radius: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 24px 20px;
  z-index: 9000;
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition: opacity 0.35s, visibility 0s 0.35s;
  border: none;
  overflow: visible;
}
.reversi-game .ot-result-modal {
  background: url("https://wakabaland.com/wp-content/uploads/2026/04/繧上°縺ｰ3.webp")
    center top / cover no-repeat;
  border-radius: 24px;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 0;
  text-align: center;
  box-shadow:
    0 16px 56px rgba(0, 0, 0, 0.8),
    0 0 0 2px rgba(255, 255, 255, 0.12);
  width: min(420px, 94vw);
  min-height: min(600px, 90vw);
  position: relative;
  overflow: hidden;
  animation: ot-drop 0.35s cubic-bezier(0.22, 1.4, 0.4, 1);
}
.reversi-game .ot-result-modal::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0%,
    rgba(0, 0, 0, 0) 45%,
    rgba(0, 0, 0, 0.72) 72%,
    rgba(0, 0, 0, 0.88) 100%
  );
  border-radius: inherit;
  pointer-events: none;
}
.reversi-game .ot-result-modal > * {
  position: relative;
  z-index: 1;
}
.reversi-game .ot-result-modal-body {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 20px 24px 28px;
}
.reversi-game .ot-overlay.result-lose .ot-result-modal {
  background-image: url("https://wakabaland.com/wp-content/uploads/2026/04/繧上°縺ｰ4.webp");
}

.reversi-game .ot-overlay::before {
  content: "";
  position: absolute;
  inset: 0;
  background: none;
  pointer-events: none;
}
.reversi-game .ot-overlay.show {
  opacity: 1;
  visibility: visible;
  transition-delay: 0s;
  pointer-events: all;
}

.reversi-game .ot-result-title {
  font-family: "DotGothic16", sans-serif;
  font-size: clamp(18px, 8vw, 52px);
  font-weight: 900;
  letter-spacing: 0.06em;
  color: #fff;
  text-align: center;
  position: relative;
  z-index: 1;
  line-height: 1.15;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
  white-space: nowrap;
}
.reversi-game .ot-overlay.result-win .ot-result-title {
  color: #fff;
}
.reversi-game .ot-overlay.result-lose .ot-result-title {
  color: #fff;
}
.reversi-game .ot-overlay.result-draw .ot-result-title {
  color: #fff;
  font-size: clamp(26px, 7vw, 40px);
}
@keyframes result-title-glow {
  0%,
  100% {
    text-shadow: none;
  }
  50% {
    text-shadow: none;
  }
}

.reversi-game .ot-result-scores {
  display: flex;
  gap: 20px;
  align-items: center;
  position: relative;
  z-index: 1;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 20px;
  padding: 16px 36px;
}
.reversi-game .ot-result-score-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.reversi-game .ot-result-disc {
  width: clamp(32px, 8vw, 44px);
  height: clamp(32px, 8vw, 44px);
  border-radius: 50%;
  box-shadow:
    0 4px 0 rgba(0, 0, 0, 0.15),
    inset 0 3px 8px rgba(255, 255, 255, 0.3);
}
.reversi-game .ot-result-disc.black {
  background: radial-gradient(circle at 36% 32%, #555, #111);
}
.reversi-game .ot-result-disc.white {
  background: radial-gradient(circle at 36% 32%, #fff, #e0e0e0);
  border: 1px solid #ddd;
}
.reversi-game .ot-result-num {
  font-family: "DotGothic16", sans-serif;
  font-size: clamp(40px, 11vw, 56px);
  color: #fff;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
  line-height: 1;
}
.reversi-game .ot-result-vs {
  font-family: "DotGothic16", sans-serif;
  font-size: clamp(18px, 4.5vw, 24px);
  color: rgba(255, 255, 255, 0.5);
}
.reversi-game .ot-result-sub {
  font-size: var(--wk-font-body, 16px);
  letter-spacing: 0.12em;
  color: rgba(255, 255, 255, 0.65);
  position: relative;
  z-index: 1;
}

.reversi-game .ot-overlay #sb-win-choice,
.reversi-game .ot-overlay #sb-lose-actions {
  position: relative;
  z-index: 1;
  width: 100%;
  padding: 0 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 16px;
}

.reversi-game .ot-overlay #sb-result-wins {
  font-family: "Fredoka One", sans-serif;
  font-size: max(var(--wk-font-min, 14px), clamp(13px, 3.5vw, 15px));
  color: #fff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
  letter-spacing: 0.08em;
  position: relative;
  z-index: 1;
}

.reversi-game .ot-overlay #sb-win-choice > div:first-child {
  font-size: max(var(--wk-font-min, 14px), clamp(13px, 3.5vw, 16px)) !important;
  color: rgba(255, 255, 255, 0.85) !important;
  letter-spacing: 0.04em;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
  margin-bottom: 0;
}
