:root {
  --bg: #f4f6f0;
  --panel: #ffffff;
  --ink: #17211b;
  --muted: #69716b;
  --line: #d6ddd4;
  --green: #168f57;
  --green-dark: #0d683e;
  --amber: #f2b84b;
  --red: #e35b53;
  --blue: #4f78d8;
  --shadow: 0 14px 38px rgba(20, 36, 26, .14);
  --title-outline:
    1px 0 #5b3912,
    -1px 0 #5b3912,
    0 1px #5b3912,
    0 -1px #5b3912,
    1px 1px #5b3912,
    -1px 1px #5b3912,
    1px -1px #5b3912,
    -1px -1px #5b3912,
    0 3px 0 rgba(82, 48, 13, .36),
    0 0 14px rgba(255, 230, 150, .55);
}

* { box-sizing: border-box; }

html {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(22,143,87,.08), transparent 38%),
    var(--bg);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

button, input { font: inherit; }

.app {
  width: min(100%, 480px);
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #fbfcf9;
  box-shadow: 0 0 0 1px rgba(0,0,0,.05);
}

.topbar {
  display: none;
  grid-template-columns: 48px 1fr 48px;
  align-items: center;
  gap: 8px;
  padding: max(12px, env(safe-area-inset-top)) 14px 10px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #151918;
  color: #f8faf5;
  outline: 2px solid #f8faf5;
  box-shadow: 0 0 0 3px #151918;
}

h1, h2, p { margin: 0; }

h1 {
  font-size: 18px;
  line-height: 1;
  letter-spacing: 0;
}

.brand p {
  margin-top: 4px;
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  text-transform: uppercase;
}

.icon-btn {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 24px;
}

main {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  padding: 14px;
}

body.title-mode main {
  padding: 0;
}

body.title-mode .topbar {
  display: none;
}

body.character-setup-mode main {
  padding: 0;
}

body.character-setup-mode .topbar {
  display: none;
}

body.menu-mode main {
  padding: 0;
}

body.menu-mode .topbar {
  display: none;
}

body.setup-mode main,
body.game-mode main {
  padding: 0;
}

body.my-page-mode main {
  padding: 0;
}

body.my-page-mode .topbar {
  display: none;
}

.ai-setup-screen {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 12px;
  height: 100%;
  min-height: 0;
  padding: 34px 14px 14px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.66), rgba(255,255,255,.5) 42%, rgba(247,252,248,.72)),
    url("assets/backgrounds/character-select-reversi-soft.png?v=2") center / cover no-repeat;
  overflow: hidden;
}

.ai-setup-title {
  width: min(100%, 460px);
  margin: 0 auto;
  text-align: center;
}

.ai-setup-title h2 {
  margin: 0;
  color: #fff1b8;
  font-family: "Meiryo", "Hiragino Kaku Gothic ProN", system-ui, sans-serif;
  font-size: clamp(34px, 9.2vw, 46px);
  font-weight: 800;
  line-height: 1.08;
  text-shadow: var(--title-outline);
}

.ai-setup-title p {
  margin-top: 8px;
  color: #164332;
  font-size: clamp(13px, 3.5vw, 16px);
  font-weight: 900;
  line-height: 1.35;
}

.ai-level-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 10px;
  width: min(100%, 680px);
  min-height: 0;
  margin: 0 auto;
  padding: 12px;
  border: 1px solid rgba(21, 58, 45, .18);
  border-radius: 8px;
  background: rgba(255,255,255,.9);
  box-shadow: 0 12px 26px rgba(22,55,38,.1);
}

.ai-level-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 46px;
  padding: 8px 10px;
  border-radius: 8px;
  background: linear-gradient(180deg, #103b31, #0b7050);
  color: #fff;
}

.ai-level-summary span {
  font-size: 12px;
  font-weight: 800;
  opacity: .8;
}

.ai-level-summary strong {
  font-size: 20px;
  line-height: 1;
}

.ai-level-groups {
  display: grid;
  gap: 10px;
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
}

.ai-level-group h3 {
  margin: 0 0 6px;
  color: #184332;
  font-size: 15px;
  line-height: 1;
}

.ai-level-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.ai-level-btn {
  position: relative;
  min-height: 38px;
  border: 1px solid rgba(18, 93, 69, .28);
  border-radius: 8px;
  background: linear-gradient(180deg, #fff, #edf5ef);
  color: #143d2f;
  font-size: 16px;
  font-weight: 900;
}

.ai-level-btn span {
  display: block;
}

.ai-level-btn small {
  display: none;
}

.ai-level-btn.is-selected {
  border-color: rgba(255,255,255,.8);
  background: linear-gradient(180deg, #1a9f60, #0b6f48);
  color: #fff;
  box-shadow: 0 8px 16px rgba(15, 83, 56, .22), inset 0 1px 0 rgba(255,255,255,.35);
}

.ai-level-btn.is-cleared::after {
  content: "✓";
  position: absolute;
  right: -5px;
  top: -6px;
  display: grid;
  place-items: center;
  width: 19px;
  height: 19px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #f2b84b;
  color: #183d31;
  font-size: 12px;
  line-height: 1;
  box-shadow: 0 4px 10px rgba(63, 39, 8, .24);
}

.ai-level-btn.is-cleared small {
  display: block;
  margin-top: 2px;
  font-size: 9px;
  line-height: 1;
  opacity: .74;
}

.ai-option-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.ai-toggle {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  padding: 8px 10px;
  border: 1px solid rgba(21, 58, 45, .16);
  border-radius: 8px;
  background: rgba(248, 251, 246, .9);
  color: #173d30;
  font-size: 13px;
  font-weight: 900;
}

.ai-toggle input {
  width: 42px;
  height: 24px;
  accent-color: var(--green);
}

.ai-setup-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  width: min(100%, 680px);
  margin: 0 auto;
}

.ai-setup-actions .primary-btn,
.ai-setup-actions .secondary-btn {
  min-height: 54px;
}

#gameView {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "opponent resign"
    "board board"
    "message message"
    "player player";
  grid-template-rows: auto auto auto auto;
  align-content: start;
  gap: 8px;
  height: 100%;
  min-height: 0;
  padding: 10px 14px 12px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.66), rgba(255,255,255,.5) 42%, rgba(247,252,248,.72)),
    url("assets/backgrounds/character-select-reversi-soft.png?v=2") center / cover no-repeat;
  overflow: hidden;
}

.view {
  display: none;
  height: 100%;
  min-height: 0;
}

.view-active { display: block; }

.title-screen {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  height: 100%;
  min-height: 0;
  padding: clamp(82px, 15vh, 132px) 14px 32px;
  overflow: hidden;
  text-align: center;
  color: #fff;
  background:
    linear-gradient(180deg, rgba(255,255,255,.08), rgba(7,32,27,.22) 45%, rgba(4,18,16,.52)),
    url("assets/title/bright-casino-lounge-02.png") center / cover no-repeat;
}

.title-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 30%, rgba(255,255,255,.2), transparent 30%),
    linear-gradient(180deg, rgba(255,255,255,.12), rgba(0,0,0,.08) 38%, rgba(0,0,0,.42));
  pointer-events: none;
}

.title-screen::after {
  content: "";
  position: absolute;
  inset: auto 10% 14% 10%;
  height: 150px;
  background: radial-gradient(ellipse, rgba(255,255,255,.22), transparent 66%);
  filter: blur(10px);
  pointer-events: none;
}

.title-orbit {
  display: none;
  position: relative;
  width: 190px;
  height: 190px;
  border: 1px solid rgba(255,255,255,.24);
  border-radius: 50%;
  box-shadow: inset 0 0 36px rgba(255,255,255,.08), 0 0 48px rgba(22,143,87,.28);
}

.title-orbit::before,
.title-orbit::after {
  content: "";
  position: absolute;
  inset: 28px;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 50%;
}

.title-orbit::after {
  inset: 58px;
}

.title-disc {
  position: absolute;
  display: block;
  width: 66px;
  height: 66px;
  border-radius: 50%;
  box-shadow: 0 12px 24px rgba(0,0,0,.28);
}

.title-disc.black-disc {
  left: 28px;
  top: 62px;
  background: radial-gradient(circle at 30% 26%, #666, #111 58%, #000);
}

.title-disc.white-disc {
  right: 28px;
  top: 62px;
  background: radial-gradient(circle at 30% 26%, #fff, #e8eee8 60%, #bfc8bf);
}

.title-logo {
  z-index: 1;
  width: min(100%, 520px);
  margin-top: 0;
  padding: 0 10px;
}

.title-logo h2 {
  margin: 0;
  color: #fff2bd;
  font-family: "Meiryo", "Hiragino Kaku Gothic ProN", system-ui, sans-serif;
  font-size: clamp(39px, 10.5vw, 52px);
  font-weight: 800;
  line-height: 1.04;
  white-space: nowrap;
  letter-spacing: 0;
  text-shadow: var(--title-outline);
  -webkit-text-stroke: 0 transparent;
}

.title-logo p {
  display: inline-block;
  max-width: min(100%, 430px);
  margin-top: 14px;
  padding: 0 4px;
  color: rgba(255,255,255,.98);
  font-size: clamp(14px, 3.8vw, 20px);
  font-weight: 900;
  line-height: 1.46;
  text-shadow:
    0 2px 8px rgba(0,0,0,.62),
    0 0 16px rgba(14,87,65,.55),
    0 0 28px rgba(255,239,185,.36);
}

.title-start {
  z-index: 1;
  width: min(100%, 270px);
  min-height: 54px;
  margin-top: clamp(118px, 18vh, 168px);
  border: 1px solid rgba(255,255,255,.72);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255,255,255,.98), rgba(255,239,194,.96));
  color: #153d2f;
  font-weight: 900;
  box-shadow: 0 16px 34px rgba(0,0,0,.24), inset 0 1px 0 rgba(255,255,255,.75);
}

.title-links {
  z-index: 1;
  display: flex;
  gap: 14px;
  margin-top: 20px;
}

.title-links button {
  border: 0;
  background: transparent;
  color: rgba(255,255,255,.72);
  font-size: 12px;
}

.hero-band {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 12px;
  border-radius: 8px;
  background: linear-gradient(135deg, #193126, #0f5d3a);
  box-shadow: var(--shadow);
}

.record {
  min-height: 70px;
  padding: 10px;
  border-radius: 8px;
  background: rgba(255,255,255,.12);
  color: #fff;
}

.record span {
  display: block;
  font-size: 12px;
  opacity: .8;
}

.record strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
  line-height: 1;
}

.mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.home-screen {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto 64px;
  gap: 10px;
  height: 100%;
  min-height: 0;
  padding: 28px 14px 12px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.58), rgba(255,255,255,.44) 42%, rgba(247,252,248,.7)),
    url("assets/backgrounds/character-select-reversi-soft.png?v=2") center / cover no-repeat;
  overflow: hidden;
}

.home-title {
  width: min(100%, 460px);
  margin: 0 auto;
  padding: 0 8px;
  text-align: center;
}

.home-title h2 {
  margin: 0;
  color: #fff1b8;
  font-family: "Meiryo", "Hiragino Kaku Gothic ProN", system-ui, sans-serif;
  font-size: clamp(39px, 10.5vw, 52px);
  font-weight: 800;
  line-height: 1.04;
  white-space: nowrap;
  text-shadow: var(--title-outline);
  -webkit-text-stroke: 0 transparent;
}

.home-title p {
  max-width: 390px;
  margin: 8px auto 0;
  color: #164332;
  font-size: clamp(13px, 3.5vw, 17px);
  font-weight: 900;
  line-height: 1.42;
  text-shadow:
    0 1px 0 rgba(255,255,255,.9),
    0 0 14px rgba(245,207,102,.34);
}

.home-main {
  display: grid;
  grid-template-columns: minmax(0, 1.22fr) minmax(126px, .78fr);
  align-items: stretch;
  gap: 8px;
  width: min(100%, 680px);
  min-height: 0;
  margin: 0 auto;
}

.home-left-column,
.home-right-column {
  display: grid;
  align-content: center;
  gap: 10px;
  min-width: 0;
}

.home-character {
  display: grid;
  align-items: end;
  justify-items: center;
  min-height: 0;
  overflow: visible;
}

.home-character img {
  display: block;
  width: min(142%, 430px);
  max-width: none;
  max-height: min(60vh, 520px);
  object-fit: contain;
  object-position: center bottom;
  transform: translateX(-5%);
  filter: drop-shadow(0 18px 22px rgba(0,0,0,.18));
}

.home-mode-grid {
  grid-template-columns: 1fr;
  gap: 14px;
  margin: 0;
  align-self: center;
}

.home-mode-card {
  justify-content: center;
  min-height: 82px;
  padding: 12px 10px;
  border: 2px solid rgba(255,255,255,.82);
  background: linear-gradient(180deg, rgba(19,91,158,.94), rgba(18,54,138,.95));
  color: #fff;
  box-shadow: 0 12px 22px rgba(12,45,72,.2), inset 0 1px 0 rgba(255,255,255,.35);
  text-align: center;
}

.home-mode-card strong {
  margin: 0;
  font-size: clamp(19px, 5vw, 26px);
  line-height: 1.15;
  text-shadow: 0 2px 0 rgba(0,0,0,.28), 0 0 14px rgba(255,255,255,.24);
}

.home-profile-card {
  background: linear-gradient(180deg, rgba(19,143,87,.96), rgba(10,92,61,.98));
}

.home-utility-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  width: min(100%, 680px);
  margin: 0 auto;
}

.home-bottom-btn {
  display: grid;
  place-items: center;
  min-height: 50px;
  padding: 7px 4px;
  border: 2px solid rgba(255,255,255,.82);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(22,132,122,.96), rgba(9,82,94,.98));
  color: #fff;
  box-shadow: 0 10px 18px rgba(12,45,72,.2), inset 0 1px 0 rgba(255,255,255,.38);
  text-align: center;
}

.home-bottom-btn strong {
  color: #fff;
  font-size: clamp(13px, 3.5vw, 17px);
  line-height: 1.12;
  text-shadow: 0 2px 0 rgba(0,0,0,.3), 0 0 12px rgba(255,255,255,.2);
}

.home-ad-slot {
  width: min(100%, 680px);
  min-height: 64px;
  margin: 0 auto;
  border: 2px dashed rgba(14,91,80,.34);
  border-radius: 8px;
  background: rgba(255,255,255,.82);
  box-shadow: 0 8px 18px rgba(12,45,72,.08);
}

.my-page-screen {
  min-height: 100vh;
  padding: 42px 14px 22px;
  color: #fff;
  background:
    linear-gradient(180deg, rgba(8,13,28,.94), rgba(5,9,18,.96)),
    radial-gradient(circle at 50% 20%, rgba(22,95,203,.46), transparent 34%),
    repeating-linear-gradient(0deg, rgba(255,255,255,.035) 0 1px, transparent 1px 4px);
}

.my-page-title {
  margin: 0 -14px 22px;
  padding: 14px;
  border-top: 1px solid rgba(255,255,255,.28);
  border-bottom: 1px solid rgba(255,255,255,.28);
  background: #050609;
  font-size: 28px;
  text-align: center;
  letter-spacing: 0;
}

.my-page-main {
  display: grid;
  grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr);
  align-items: center;
  gap: 10px;
  width: min(100%, 680px);
  margin: 0 auto;
}

.my-page-character {
  display: grid;
  align-items: end;
  justify-items: center;
  min-height: 430px;
}

.my-page-character img {
  display: block;
  width: min(124%, 310px);
  max-width: none;
  max-height: 470px;
  object-fit: contain;
  object-position: center bottom;
  filter: drop-shadow(0 16px 0 rgba(255,255,255,.8)) drop-shadow(0 20px 24px rgba(0,0,0,.38));
}

.my-page-panel {
  padding: 8px;
  border: 2px solid #58d4ff;
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(235,239,244,.92), rgba(188,196,205,.94));
  color: #2b2f35;
  box-shadow: 0 18px 28px rgba(0,0,0,.28);
}

.my-page-name {
  display: flex;
  align-items: center;
  min-height: 56px;
  padding: 10px 12px;
  border-radius: 6px;
  background: linear-gradient(180deg, #f4f6f8, #c9d0d8);
  font-size: clamp(18px, 4.5vw, 24px);
  font-weight: 900;
}

.my-page-section-label {
  width: 76%;
  margin: 10px auto 12px;
  padding: 5px;
  border: 2px solid #4db7d6;
  border-top: 0;
  color: #303741;
  font-size: 15px;
  font-weight: 900;
  text-align: center;
}

.my-page-stat-list {
  display: grid;
  gap: 10px;
}

.my-page-stat-list div {
  display: grid;
  grid-template-columns: 72px 1fr;
  align-items: center;
  min-height: 48px;
  padding: 8px 12px;
  border-radius: 6px;
  background: linear-gradient(180deg, #f8f9fa, #cfd3d8);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.86), 0 2px 8px rgba(0,0,0,.12);
}

.my-page-stat-list span,
.my-page-stat-list strong {
  font-size: clamp(17px, 4.2vw, 23px);
  font-weight: 900;
  line-height: 1.15;
}

.my-page-stat-list strong {
  text-align: right;
}

.my-page-history-panel {
  width: min(100%, 680px);
  margin: 18px auto 0;
  padding: 12px;
  border: 2px solid #58d4ff;
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(235,239,244,.94), rgba(188,196,205,.95));
  color: #2b2f35;
  box-shadow: 0 18px 28px rgba(0,0,0,.22);
}

.my-page-history-panel h3 {
  margin: 0 0 10px;
  font-size: clamp(18px, 4.6vw, 23px);
  line-height: 1.15;
}

.match-history-list {
  display: grid;
  gap: 8px;
}

.match-history-item {
  display: grid;
  grid-template-columns: 70px 74px 1fr;
  align-items: center;
  gap: 8px;
  min-height: 58px;
  padding: 8px 10px;
  border: 1px solid rgba(31,88,117,.34);
  border-radius: 8px;
  background: linear-gradient(180deg, #fff, #edf3f5);
  color: #26323a;
  text-align: left;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.9), 0 2px 8px rgba(0,0,0,.1);
}

.match-history-item span,
.match-history-item small {
  color: #52626c;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.25;
}

.match-history-item strong {
  color: #0f4f82;
  font-size: 17px;
  font-weight: 1000;
  line-height: 1.1;
}

.match-history-empty {
  margin: 0;
  padding: 12px;
  border-radius: 8px;
  background: rgba(255,255,255,.78);
  color: #52626c;
  font-weight: 800;
  text-align: center;
}

.my-page-home-btn {
  display: block;
  width: min(100%, 280px);
  min-height: 58px;
  margin: 26px auto 0;
  border: 2px solid rgba(255,255,255,.75);
  border-radius: 999px;
  background: linear-gradient(180deg, #158fce, #073978);
  color: #fff;
  font-size: 20px;
  font-weight: 900;
  box-shadow: 0 12px 22px rgba(0,0,0,.24), inset 0 1px 0 rgba(255,255,255,.45);
}

.mode-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 126px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 8px 20px rgba(21, 32, 27, .08);
  text-align: left;
}

.mode-card strong {
  display: block;
  margin: 8px 0;
  font-size: 22px;
  line-height: 1.05;
}

.profile-card strong {
  font-size: 18px;
  overflow-wrap: anywhere;
}

.locked-card {
  opacity: .78;
}

.mode-kicker, .mode-card small, .section-title span, .hint {
  color: var(--muted);
  font-size: 12px;
}

.characters {
  margin-top: 18px;
}

.section-title {
  display: flex;
  align-items: end;
  justify-content: space-between;
  margin-bottom: 8px;
}

.section-title h2, .setup-panel h2, .dialog-body h2 {
  font-size: 18px;
}

.character-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.character {
  min-height: 210px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.character.is-locked {
  opacity: .55;
}

.character-list-wide {
  grid-template-columns: repeat(2, 1fr);
}

.character.is-selected {
  border-color: var(--green);
  box-shadow: 0 0 0 2px rgba(22, 143, 87, .2);
}

.avatar {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  margin: 10px auto 6px;
  border-radius: 50%;
  color: #fff;
  font-weight: 800;
}

.character-art {
  display: block;
  height: 176px;
  margin: 0;
  background: linear-gradient(180deg, #f8faf7, #e9eee7);
  overflow: hidden;
}

.character-art img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
}

.character small {
  display: block;
  min-height: 34px;
  padding: 7px 4px 8px;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.setup-panel {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.character-setup-panel {
  height: 100%;
  min-height: 0;
  padding: 34px 14px 14px;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background:
    linear-gradient(180deg, rgba(255,255,255,.58), rgba(255,255,255,.44) 42%, rgba(247,252,248,.7)),
    url("assets/backgrounds/character-select-reversi-soft.png?v=2") center / cover no-repeat;
  box-shadow: none;
}

.character-setup-title {
  width: min(100%, 460px);
  margin: 0 auto 12px;
  padding: 0 8px;
  text-align: center;
}

.character-setup-title h2 {
  margin: 0;
  color: #fff1b8;
  font-family: "Meiryo", "Hiragino Kaku Gothic ProN", system-ui, sans-serif;
  font-size: clamp(39px, 10.5vw, 52px);
  font-weight: 800;
  line-height: 1.04;
  white-space: nowrap;
  text-shadow: var(--title-outline);
  -webkit-text-stroke: 0 transparent;
}

.character-setup-title p {
  max-width: 390px;
  margin: 10px auto 0;
  color: #164332;
  font-size: clamp(13px, 3.5vw, 17px);
  font-weight: 900;
  line-height: 1.42;
  text-shadow:
    0 1px 0 rgba(255,255,255,.9),
    0 0 14px rgba(245,207,102,.34);
}

.character-select-heading {
  font-size: clamp(15px, 3.8vw, 18px);
  text-align: center;
  margin: 8px 0 10px;
  color: #8a5a12;
  font-weight: 900;
  line-height: 1.35;
  text-shadow: 0 1px 0 rgba(255,255,255,.8), 0 0 12px rgba(255,222,145,.36);
}

.onboarding-title {
  margin-top: 18px;
}

.character-carousel {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) 56px;
  align-items: center;
  gap: 8px;
  width: min(100%, 680px);
  margin: 0 auto;
}

.carousel-arrow {
  position: relative;
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(180deg, #168f57, #0f6c43);
  color: #fff;
  font-size: 34px;
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 10px 20px rgba(21, 32, 27, .14);
  font-size: 0;
}

.carousel-arrow::before {
  content: "";
  display: block;
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0;
  height: 0;
  border-top: 11px solid transparent;
  border-bottom: 11px solid transparent;
}

#prevCharacterBtn::before {
  border-right: 14px solid #fff;
  transform: translate(-57%, -50%);
}

#nextCharacterBtn::before {
  border-left: 14px solid #fff;
  transform: translate(-43%, -50%);
}

.character-stage {
  display: grid;
  place-items: center;
  height: clamp(300px, 49dvh, 520px);
  min-height: 0;
  border-radius: 0;
  background: transparent;
  overflow: hidden;
  box-shadow: none;
}

.character-stage img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center bottom;
  filter: drop-shadow(0 16px 20px rgba(0,0,0,.18));
}

.character-profile-panel {
  width: min(100%, 680px);
  margin: 10px auto 0;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid rgba(21, 58, 45, .18);
  background: rgba(255,255,255,.9);
  backdrop-filter: blur(8px);
  color: #173d30;
  box-shadow: 0 12px 26px rgba(22,55,38,.1);
}

.character-profile-panel h3 {
  margin: 0 0 8px;
  font-size: 20px;
  line-height: 1.1;
}

.character-profile-panel p {
  min-height: 62px;
  font-size: 14px;
  line-height: 1.55;
  color: #40574d;
}

.field {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.field span {
  color: var(--muted);
  font-size: 13px;
}

.field input[type="url"],
.field input[type="text"] {
  width: 100%;
  height: 46px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.field output {
  justify-self: end;
  color: var(--green-dark);
  font-weight: 800;
}

.switch-row {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.switch-row input {
  width: 48px;
  height: 28px;
  accent-color: var(--green);
}

.primary-btn, .secondary-btn {
  width: 100%;
  min-height: 48px;
  border-radius: 8px;
  border: 0;
  font-weight: 800;
}

.primary-btn {
  margin-top: 18px;
  background: var(--green);
  color: #fff;
}

.secondary-btn {
  background: #eef2ed;
  color: var(--ink);
  border: 1px solid var(--line);
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.button-row .primary-btn,
.button-row .secondary-btn {
  min-height: 52px;
  margin-top: 0;
}

.status-line {
  min-height: 20px;
  margin-top: 12px;
  color: var(--green-dark);
  font-size: 13px;
}

.rate-range-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 16px;
}

.range-btn {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
}

.range-btn.is-selected {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}

.widen-prompt {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.widen-prompt p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.error-line {
  min-height: 18px;
  margin-top: 8px;
  color: var(--red);
  font-size: 12px;
}

.ad-slot {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  margin-top: 14px;
  padding: 10px 12px;
  border: 1px dashed #b8c2b8;
  border-radius: 8px;
  background: #f5f7f3;
  color: var(--muted);
}

.ad-slot[hidden] {
  display: none;
}

.ad-slot span {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 6px;
  background: #dfe6dc;
  color: #506057;
  font-size: 12px;
  font-weight: 800;
}

.stat-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.stat-list div {
  min-height: 78px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.stat-list span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.stat-list strong {
  display: block;
  margin-top: 8px;
  font-size: 26px;
}

.shop-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.shop-item {
  width: 100%;
  min-height: 96px;
}

.settings-profile {
  display: grid;
  gap: 4px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.settings-profile span {
  font-size: 18px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.settings-profile strong,
.settings-profile small {
  color: var(--muted);
  font-size: 12px;
}

.settings-links {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.settings-links .secondary-btn {
  min-height: 42px;
  font-size: 13px;
}

.settings-wide-btn {
  margin-top: 10px;
}

.score-strip {
  display: contents;
}

.score {
  display: grid;
  grid-template-columns: 50px 1fr;
  align-items: center;
  gap: 10px;
  min-height: 76px;
  padding: 9px 12px;
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255,255,255,.97), rgba(236,242,238,.97));
  border: 1px solid rgba(255,255,255,.55);
  box-shadow: 0 10px 24px rgba(15, 32, 22, .18);
}

.score span {
  grid-row: span 2;
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  font-size: 14px;
  overflow: hidden;
}

.score span img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
}

.score.black span { background: #111; color: #fff; }
.score.white span { background: #fff; color: #111; border: 1px solid #999; }

.score.black { grid-area: black; }
.score.white { grid-area: white; }

body.human-black .score.black,
body.human-white .score.white,
body:not(.human-white):not(.human-black) .score.black {
  grid-area: player;
}

body.human-black .score.white,
body.human-white .score.black,
body:not(.human-white):not(.human-black) .score.white {
  grid-area: opponent;
}

.score-main {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.score em {
  color: #355044;
  font-size: clamp(13px, 3.5vw, 17px);
  font-style: normal;
  font-weight: 1000;
  line-height: 1;
}

.score strong {
  color: #10281f;
  font-size: clamp(30px, 8.5vw, 42px);
  line-height: .92;
}

.score small {
  color: #163d30;
  font-size: clamp(18px, 5.1vw, 27px);
  font-weight: 1000;
  line-height: 1.12;
}

body.cpu-game-mode.human-black .score.black small,
body.cpu-game-mode.human-white .score.white small {
  font-size: clamp(24px, 7.2vw, 38px);
  letter-spacing: 0;
}

body.cpu-game-mode.human-black .score.white small,
body.cpu-game-mode.human-white .score.black small,
.score small:empty {
  display: none;
}

.score.is-low {
  border-color: var(--red);
  box-shadow: 0 0 0 2px rgba(227, 91, 83, .16);
}

.turn-pill {
  display: none;
  min-height: 48px;
  place-items: center;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(180deg, #111, #2a2a2a);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  text-align: center;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.12);
}

.turn-pill.white-turn {
  background: #fff;
  color: #111;
  border: 1px solid #aaa;
}

.resign-btn {
  grid-area: resign;
  align-self: stretch;
  min-width: 74px;
  min-height: 56px;
  padding: 0 12px;
  border: 1px solid rgba(255,255,255,.72);
  border-radius: 8px;
  background: linear-gradient(180deg, #fc7b72, #b72f2c);
  color: #fff;
  font-size: 18px;
  font-weight: 1000;
  box-shadow: 0 10px 22px rgba(103, 24, 24, .22), inset 0 1px 0 rgba(255,255,255,.42);
}

.board {
  grid-area: board;
  width: 100%;
  max-width: 452px;
  margin: clamp(32px, 7vh, 60px) auto 0;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  aspect-ratio: 1;
  padding: 8px;
  gap: 2px;
  border: 6px solid #15241c;
  border-radius: 10px;
  background: #0b4d32;
  box-shadow:
    0 16px 36px rgba(13, 34, 22, .26),
    inset 0 0 0 2px rgba(255,255,255,.08);
  touch-action: manipulation;
}

.message {
  grid-area: message;
}

.cell {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  border: 0;
  border-radius: 3px;
  background:
    linear-gradient(135deg, rgba(255,255,255,.08), transparent 42%),
    #158f57;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.2);
  perspective: 520px;
}

.cell.guide::after {
  content: "";
  width: 30%;
  height: 30%;
  border-radius: 50%;
  background: rgba(255, 211, 91, .95);
  box-shadow: 0 0 0 4px rgba(255, 211, 91, .18);
}

.disc {
  position: relative;
  width: 80%;
  height: 80%;
  border-radius: 50%;
  box-shadow:
    0 5px 9px rgba(0,0,0,.32),
    inset 0 1px 2px rgba(255,255,255,.25);
  transform: scale(.96);
  transform-style: preserve-3d;
}

.disc.black { background: radial-gradient(circle at 32% 26%, #5d5d5d, #111 58%, #000 100%); }
.disc.white { background: radial-gradient(circle at 32% 26%, #fff, #eef1ed 58%, #cfd6cf 100%); }

.disc.is-placed {
  animation: discPlace .22s ease-out;
}

.disc.is-flipped {
  background:
    linear-gradient(90deg,
      #f7f8f5 0 23%,
      #d2c091 37%,
      #80613d 50%,
      #1a1a1a 63%,
      #020202 100%);
  box-shadow:
    0 6px 10px rgba(0,0,0,.34),
    inset 0 0 0 1px rgba(255,255,255,.34);
  animation: discFlip .32s cubic-bezier(.22,.8,.22,1) both;
}

.disc.is-flipped::before,
.disc.is-flipped::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  backface-visibility: hidden;
  box-shadow:
    inset 0 1px 2px rgba(255,255,255,.3),
    inset 0 -4px 8px rgba(0,0,0,.24);
}

.disc.is-flipped::after {
  transform: rotateY(180deg);
}

.disc.black.is-flipped::before,
.disc.white.is-flipped::after {
  background:
    radial-gradient(circle at 32% 24%, #fff 0 15%, #eef1ed 46%, #c7cec7 100%);
}

.disc.white.is-flipped::before,
.disc.black.is-flipped::after {
  background:
    radial-gradient(circle at 32% 24%, #666 0 13%, #171717 55%, #000 100%);
}

.disc.is-flipped::before {
  outline: 1px solid rgba(0,0,0,.32);
}

.disc.is-flipped::after {
  outline: 1px solid rgba(255,255,255,.28);
}

@keyframes discPlace {
  from { transform: scale(.24); opacity: .35; }
  to { transform: scale(.96); opacity: 1; }
}

@keyframes discFlip {
  0% {
    transform: scale(.96) rotateY(0deg);
  }
  28% {
    transform: scale(.96) rotateY(54deg);
  }
  44% {
    transform: scale(.96) rotateY(82deg);
    box-shadow: 0 8px 14px rgba(0,0,0,.38);
  }
  49% {
    transform: scale(.96) rotateY(90deg);
    box-shadow:
      0 8px 14px rgba(0,0,0,.38),
      inset 0 0 0 4px rgba(126, 93, 55, .88);
  }
  54% {
    transform: scale(.96) rotateY(92deg);
    box-shadow:
      0 8px 14px rgba(0,0,0,.38),
      inset 0 0 0 4px rgba(126, 93, 55, .88);
  }
  64% {
    transform: scale(.96) rotateY(112deg);
  }
  78% {
    transform: scale(.96) rotateY(142deg);
  }
  100% {
    transform: scale(.96) rotateY(180deg);
  }
}

.game-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.match-info {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.match-info div {
  min-height: 48px;
  padding: 8px 10px;
  border: 1px solid #c8d4ca;
  border-radius: 8px;
  background: linear-gradient(180deg, #fff, #f2f6f1);
}

.match-info span {
  display: block;
  color: var(--muted);
  font-size: 10px;
}

.match-info strong {
  display: block;
  margin-top: 4px;
  font-size: 20px;
  line-height: 1;
}

.message {
  min-height: 42px;
  margin-top: 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: #102a20;
  border: 1px solid rgba(255,255,255,.12);
  color: #fff;
  text-align: center;
  font-weight: 800;
  box-shadow: 0 10px 24px rgba(16, 42, 32, .18);
}

.resign-confirm {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(8, 18, 14, .48);
  backdrop-filter: blur(3px);
}

.resign-confirm[hidden] {
  display: none;
}

.resign-dialog {
  width: min(100%, 330px);
  padding: 22px 18px 18px;
  border: 1px solid rgba(255,255,255,.72);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255,255,255,.98), rgba(236,242,238,.98));
  color: #10281f;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0,0,0,.28);
}

.resign-dialog h2 {
  margin: 0 0 16px;
  font-size: 24px;
  font-weight: 1000;
  line-height: 1.2;
}

.resign-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.danger-btn {
  min-height: 52px;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(180deg, #f06f66, #b72f2c);
  color: #fff;
  font-size: 18px;
  font-weight: 1000;
  box-shadow: 0 10px 20px rgba(130, 28, 28, .22);
}

.message.is-alert {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 40;
  min-width: min(82vw, 340px);
  min-height: 72px;
  display: grid;
  place-items: center;
  margin: 0;
  transform: translate(-50%, -50%);
  border: 2px solid rgba(255,255,255,.8);
  background: linear-gradient(180deg, rgba(17,67,50,.96), rgba(8,38,30,.98));
  color: #fff;
  font-size: clamp(20px, 5.4vw, 28px);
  box-shadow: 0 22px 54px rgba(0,0,0,.34);
}

.result-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(5, 10, 9, .76);
  backdrop-filter: blur(1.5px);
}

.result-overlay[hidden] {
  display: none;
}

.result-cutscene {
  position: relative;
  display: grid;
  align-content: end;
  justify-items: center;
  width: min(100%, 430px);
  min-height: min(76dvh, 690px);
  padding: 16px 14px 18px;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.result-cutscene[hidden] {
  display: none;
}

.result-cutscene-stage {
  position: absolute;
  inset: 0 0 94px;
  display: grid;
  place-items: end center;
  padding-top: 12px;
  overflow: visible;
}

.result-cutscene-stage::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 54%;
  width: min(90%, 350px);
  height: min(114%, 700px);
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 24px 70px rgba(0,0,0,.28);
}

.result-overlay.is-win .result-cutscene-stage::before,
.result-overlay.is-lose .result-cutscene-stage::before {
  display: none;
}

.result-cutscene-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.result-cutscene[data-sequence="video"] .result-cutscene-video {
  z-index: 2;
  object-fit: cover;
  clip-path: ellipse(41% 47% at 50% 52%);
  filter: none;
}

.result-cutscene-canvas {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 22px 28px rgba(0,0,0,.45));
}

.result-cutscene-canvas[hidden] {
  display: none;
}

.result-cutscene-image {
  position: relative;
  z-index: 2;
  width: min(86%, 330px);
  max-height: 78%;
  object-fit: contain;
  object-position: center bottom;
  filter: drop-shadow(0 18px 24px rgba(0,0,0,.38));
}

.result-cutscene-image[hidden] {
  display: none;
}

.result-cutscene-fallback {
  position: absolute;
  left: 50%;
  top: 18px;
  z-index: 4;
  display: grid;
  gap: 4px;
  width: min(86%, 330px);
  padding: 10px 12px;
  transform: translateX(-50%);
  border: 1px solid rgba(255,255,255,.5);
  border-radius: 8px;
  background: rgba(9, 20, 24, .74);
  color: #fff;
  text-align: center;
  backdrop-filter: blur(7px);
}

.result-cutscene-fallback[hidden] {
  display: none;
}

.result-cutscene-fallback span {
  font-size: 15px;
  font-weight: 1000;
}

.result-cutscene-fallback small {
  font-size: 11px;
  font-weight: 800;
  line-height: 1.35;
  opacity: .82;
}

.result-cutscene-burst {
  position: absolute;
  inset: 12% 8% 18%;
  z-index: 1;
  border-radius: 50%;
  background:
    conic-gradient(from 10deg, transparent 0 8deg, rgba(255,230,132,.5) 8deg 11deg, transparent 11deg 32deg),
    radial-gradient(circle, rgba(255,245,181,.5), transparent 54%);
  opacity: .68;
  animation: resultBurst 2.8s ease-out both;
}

.result-cutscene-copy {
  position: relative;
  z-index: 3;
  display: grid;
  justify-items: center;
  width: 100%;
  margin-top: auto;
  padding: 0 12px 48px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #fff;
  text-align: center;
  backdrop-filter: none;
}

.result-cutscene-copy span {
  color: #fff;
  font-family: Arial, "Segoe UI", sans-serif;
  font-size: clamp(60px, 18vw, 92px);
  line-height: .88;
  font-weight: 1000;
  letter-spacing: 0;
  -webkit-text-stroke: 0;
  text-rendering: geometricPrecision;
  text-shadow:
    0 5px 0 rgba(0,0,0,.35),
    0 18px 34px rgba(0,0,0,.46);
}

.result-cutscene-copy strong {
  display: none;
}

.result-cutscene-copy p {
  display: none;
}

.result-cutscene-skip {
  position: relative;
  z-index: 3;
  width: min(100%, 240px);
  min-height: 46px;
  margin-top: -32px;
  background: rgba(255,255,255,.92);
  font-weight: 900;
}

.result-overlay.is-win .result-cutscene {
  background: transparent;
}

.result-overlay.is-win .result-cutscene[data-keyed="true"],
.result-overlay.is-lose .result-cutscene[data-keyed="true"] {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

.result-overlay.is-lose .result-cutscene[data-keyed="true"] {
  border-color: rgba(186, 199, 221, .44);
  background: transparent;
  box-shadow: none;
}

.result-overlay.is-win .result-cutscene-stage::before,
.result-overlay.is-win .result-cutscene[data-keyed="true"] .result-cutscene-stage::before {
  background: #fff;
  box-shadow:
    0 20px 54px rgba(16, 88, 61, .12),
    inset 0 0 0 1px rgba(19, 148, 94, .08);
}

.result-overlay.is-win .result-cutscene[data-sequence="true"] .result-cutscene-stage::before {
  top: 52%;
  width: min(86%, 340px);
  height: min(124%, 760px);
}

.result-overlay.is-lose .result-cutscene-stage::before,
.result-overlay.is-lose .result-cutscene[data-keyed="true"] .result-cutscene-stage::before {
  background: #1b2234;
}

.result-overlay.is-win .result-cutscene[data-keyed="true"] .result-cutscene-video,
.result-overlay.is-lose .result-cutscene[data-keyed="true"] .result-cutscene-video {
  opacity: 0;
}

.result-overlay.is-win .result-cutscene[data-keyed="true"] .result-cutscene-burst,
.result-overlay.is-lose .result-cutscene[data-keyed="true"] .result-cutscene-burst {
  z-index: 1;
  opacity: .36;
}

.result-overlay.is-win .result-cutscene[data-keyed="true"] .result-cutscene-burst {
  display: none;
}

.result-overlay.is-win .result-cutscene[data-keyed="true"] .result-cutscene-copy,
.result-overlay.is-lose .result-cutscene[data-keyed="true"] .result-cutscene-copy {
  background: transparent;
  box-shadow: none;
}

.result-overlay.is-lose .result-cutscene[data-keyed="true"] .result-cutscene-copy {
  background: transparent;
}

.result-overlay.is-win .result-cutscene-copy span {
  color: #22d782;
  -webkit-text-stroke: 0;
  text-shadow:
    0 4px 0 rgba(2, 52, 33, .72),
    0 0 18px rgba(255,255,255,.5),
    0 18px 36px rgba(0,0,0,.58);
}

.result-overlay.is-win .result-cutscene-skip {
  border: 1px solid rgba(16, 148, 94, .18);
  background: rgba(255,255,255,.96);
  box-shadow: 0 10px 28px rgba(16, 88, 61, .12);
}

.result-overlay.is-lose .result-cutscene-copy span {
  color: #f1f5ff;
  -webkit-text-stroke: 0;
  text-shadow:
    0 4px 0 rgba(11, 17, 31, .78),
    0 0 16px rgba(116, 139, 190, .42),
    0 16px 30px rgba(0,0,0,.58);
}

.result-overlay.is-win .result-cutscene-image {
  width: min(88%, 340px);
  max-height: 88%;
  animation: resultCharacterWinStill .36s ease-out both;
  filter: brightness(1.08) drop-shadow(0 22px 26px rgba(0,0,0,.56));
}

.result-overlay.is-lose .result-cutscene {
  background: transparent;
}

.result-overlay.is-lose .result-cutscene-burst {
  opacity: .22;
  background: radial-gradient(circle, rgba(150,177,217,.42), transparent 58%);
}

.result-overlay.is-lose .result-cutscene-image {
  width: min(78%, 302px);
  max-height: 86%;
  animation: resultCharacterLoseStill .36s ease-out both;
  filter: grayscale(.1) brightness(.96) drop-shadow(0 22px 26px rgba(0,0,0,.56));
}

.result-overlay.is-draw .result-cutscene-image {
  animation: resultCharacterDraw 2.1s ease-in-out both;
}

.result-cutscene[data-asset="fallback"] .result-cutscene-image {
  opacity: .52;
  animation: resultFallbackStill .5s ease-out both;
}

.result-cutscene[data-asset="fallback"] .result-cutscene-burst {
  opacity: .18;
  animation: none;
}

@keyframes resultCharacterWinStill {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes resultCharacterLoseStill {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes resultCharacterDraw {
  0% { transform: translateY(20px) scale(.92); opacity: 0; }
  34% { transform: translateY(0) scale(1); opacity: 1; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}

@keyframes resultBurst {
  0% { transform: scale(.5) rotate(0deg); opacity: 0; }
  35% { opacity: .72; }
  100% { transform: scale(1.28) rotate(38deg); opacity: .08; }
}

@keyframes resultFallbackStill {
  from { opacity: 0; transform: scale(.98); }
  to { opacity: .52; transform: scale(1); }
}

.result-panel {
  width: min(100%, 420px);
  padding: 16px;
  border-radius: 8px;
  background: linear-gradient(180deg, #fff, #f4f8f2);
  box-shadow: 0 24px 60px rgba(0,0,0,.28);
  text-align: center;
}

.result-panel img {
  width: 118px;
  height: 118px;
  object-fit: cover;
  object-position: top center;
  border-radius: 50%;
  border: 4px solid #fff;
  box-shadow: 0 10px 24px rgba(0,0,0,.18);
}

.result-panel h2 {
  margin-top: 10px;
  font-size: 30px;
}

.result-panel p {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.55;
}

.result-rating {
  display: grid;
  gap: 4px;
  margin: 14px auto 0;
  width: 150px;
  padding: 10px;
  border-radius: 8px;
  background: #102a20;
  color: #fff;
}

.result-rating[hidden] {
  display: none;
}

.result-rating span {
  font-size: 11px;
  opacity: .75;
}

.result-rating strong {
  font-size: 28px;
  line-height: 1;
}

.result-replay-btn {
  width: 100%;
  min-height: 48px;
  margin: 14px 0 10px;
  font-weight: 900;
}

.replay-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 14px;
  background: rgba(4, 9, 14, .78);
}

.replay-overlay[hidden] {
  display: none;
}

.replay-panel {
  width: min(100%, 430px);
  max-height: calc(100dvh - 28px);
  overflow: auto;
  padding: 12px;
  border: 2px solid rgba(255,255,255,.82);
  border-radius: 8px;
  background: linear-gradient(180deg, #f9fbf7, #edf3ec);
  box-shadow: 0 24px 70px rgba(0,0,0,.42);
}

.replay-header {
  display: grid;
  grid-template-columns: 1fr 46px;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.replay-kicker {
  display: block;
  color: #0c6b51;
  font-size: 12px;
  font-weight: 900;
  line-height: 1.2;
}

.replay-header h2 {
  margin: 2px 0 0;
  color: #102a20;
  font-size: clamp(19px, 5vw, 26px);
  line-height: 1.1;
}

.replay-header .icon-btn {
  width: 44px;
  height: 44px;
}

.replay-board {
  width: min(100%, 398px);
  margin: 0 auto;
  border-width: 5px;
}

.replay-board .cell {
  pointer-events: none;
}

.replay-board .replay-last-move::before {
  content: "";
  position: absolute;
  inset: 8%;
  border: 3px solid rgba(255, 216, 88, .96);
  border-radius: 6px;
  box-shadow: 0 0 10px rgba(255, 216, 88, .34);
}

.replay-info {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
  min-height: 54px;
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #102a20;
  color: #fff;
}

.replay-info strong {
  font-size: clamp(16px, 4.3vw, 20px);
  line-height: 1.2;
}

.replay-info span {
  font-size: 14px;
  font-weight: 900;
  white-space: nowrap;
}

.replay-controls {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.replay-controls button {
  min-height: 46px;
  padding: 8px 4px;
  font-size: 14px;
  font-weight: 900;
}

.replay-controls button:disabled {
  opacity: .45;
}

dialog {
  width: min(92vw, 420px);
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

.dialog-body { padding: 16px; }

body.left-hand .topbar {
  grid-template-columns: 48px 1fr 48px;
  direction: rtl;
}

body.left-hand .topbar > * { direction: ltr; }

body.menu-mode #adSlot {
  display: flex;
}

body.menu-mode .home-mode-grid {
  grid-template-columns: 1fr;
  gap: 14px;
  margin: 0;
}

body.menu-mode .home-utility-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 0 auto;
}

body.menu-mode .home-mode-card {
  justify-content: center;
  min-height: 82px;
  padding: 12px 10px;
  border: 2px solid rgba(255,255,255,.82);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(20,104,184,.96), rgba(17,64,151,.98));
  color: #fff;
  box-shadow: 0 12px 22px rgba(12,45,72,.24), inset 0 1px 0 rgba(255,255,255,.4);
  text-align: center;
}

body.menu-mode .home-mode-card strong {
  margin: 0;
  color: #fff;
  font-size: clamp(19px, 5vw, 26px);
  line-height: 1.15;
  text-shadow: 0 2px 0 rgba(0,0,0,.32), 0 0 14px rgba(255,255,255,.24);
}

body.menu-mode .home-bottom-btn {
  min-height: 50px;
  border: 2px solid rgba(255,255,255,.82);
  border-radius: 8px;
  color: #fff;
  text-align: center;
}

body.menu-mode .home-bottom-btn strong {
  color: #fff;
  font-size: clamp(13px, 3.5vw, 17px);
  line-height: 1.12;
  text-shadow: 0 2px 0 rgba(0,0,0,.3), 0 0 12px rgba(255,255,255,.2);
}

@media (min-width: 760px) {
  .app {
    margin-top: 24px;
    margin-bottom: 24px;
    min-height: calc(100vh - 48px);
    border-radius: 16px;
    overflow: hidden;
  }
}
