:root {
  --zoom: 1.0;
  --zoom-tiles: calc(((34 * var(--zoom)) - 4) / (34 - 4));
  --tile-img-width: calc(var(--zoom-tiles) * 30px);
  --tile-img-height: calc(var(--tile-img-width) * 4 / 3);
  --tile-width: calc(var(--tile-img-width) + 4px);
  --tile-height: calc(var(--tile-img-height) + 4px);
}

@media (max-width: 680px) {
  :root {
    --zoom: calc((100vw - 16px) / 655);
    --zoom-tiles: calc(((34 * var(--zoom)) - 4) / (34 - 4));
    --tile-img-width: calc(var(--zoom-tiles) * 30px);
    --tile-img-height: calc(var(--tile-img-width) * 4 / 3);
    --tile-width: calc(var(--tile-img-width) + 4px);
    --tile-height: calc(var(--tile-img-height) + 4px);
  }
}

@media (max-width: 380px) {
  :root {
    --zoom: calc((100vw - 8px) / 655);
    --zoom-tiles: calc(((34 * var(--zoom)) - 4) / (34 - 4));
    --tile-img-width: calc(var(--zoom-tiles) * 30px);
    --tile-img-height: calc(var(--tile-img-width) * 4 / 3);
    --tile-width: calc(var(--tile-img-width) + 4px);
    --tile-height: calc(var(--tile-img-height) + 4px);
  }
}

:root {

  /* Apple iOS / macOS HIG Dark Mode Palette */
  --color-main: #000000;
  --color-accent: #161618;
  --color-accent2: #1c1c1e;
  --color-accent3: #2c2c2e;
  --color-hover: rgba(255, 255, 255, 0.08);
  --color-text: rgba(235, 235, 245, 0.65);
  --color-text-bright: #ffffff;
  --color-text-tertiary: rgba(235, 235, 245, 0.38);

  /* Apple System Accent Colors */
  --apple-blue: #0a84ff;
  --apple-blue-hover: #0071e3;
  --apple-green: #30d158;
  --apple-green-hover: #34c759;
  --apple-red: #ff453a;
  --apple-orange: #ff9f0a;

  /* AI Recommendation / Engine colors mapped to Apple HIG */
  --color-bar-mortal: #30d158;
  --color-bar-mortal-bright: #34c759;
  --color-mismatch: #ff453a;

  /* Discard tsumogiri shading & tiles */
  --color-tsumogiri: #d1d1d6;
  --brightness-tsumogiri: 82%;
  --color-tile-bg: #f2f2f7;
  --opacity-called: 0.32;

  /* Apple Material, Borders & Shadows */
  --apple-border: 1px solid rgba(255, 255, 255, 0.12);
  --apple-border-subtle: 1px solid rgba(255, 255, 255, 0.08);
  --apple-border-strong: 1px solid rgba(255, 255, 255, 0.2);
  --apple-card-bg: rgba(28, 28, 30, 0.72);
  --apple-card-elevated: rgba(44, 44, 46, 0.75);
  --apple-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
  --apple-shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.6);
  --apple-blur: blur(20px);
  --color-bg-gradient: radial-gradient(ellipse at 50% 15%, #1c1c24 0%, #08080a 75%);
  --color-table-bg: linear-gradient(135deg, #18181b 0%, #202025 100%);
  --color-table-border: rgba(255, 255, 255, 0.14);
  --color-table-shadow: 0 12px 40px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  --color-text-secondary: rgba(235, 235, 245, 0.65);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-user-select: none;
  user-select: none;
}

input, textarea {
  -webkit-user-select: text;
  user-select: text;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: var(--color-text);
  line-height: 1.5;
  background-color: var(--color-main);
  background-image: var(--color-bg-gradient);
  background-attachment: fixed;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  transition: background 0.3s ease, color 0.3s ease;
}

a {
  color: var(--apple-blue);
  text-decoration: none;
  transition: opacity 0.15s ease;
}

a:hover {
  opacity: 0.8;
  text-decoration: underline;
}

button, select, option, input {
  font: inherit;
  outline: none;
}

button {
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.25, 1, 0.5, 1);
}

.hidden {
  display: none !important;
}

/* ============================================================================
   Tier 1: Minimal Landing Page (Apple HIG Aesthetic)
   ============================================================================ */
.kd-tier1 {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  background: radial-gradient(ellipse at 50% 25%, #1c1c24 0%, #000000 80%);
}

.kd-landing-card {
  max-width: 480px;
  width: 100%;
  background: rgba(28, 28, 30, 0.75);
  backdrop-filter: blur(25px);
  -webkit-backdrop-filter: blur(25px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 20px;
  padding: 44px 36px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.15);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  text-align: center;
}

.kd-avatar-wrap {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  padding: 3px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.35) 0%, rgba(255, 255, 255, 0.08) 100%);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
}

.kd-avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

.kd-landing-title {
  font-size: 26px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.5px;
}

.kd-landing-sub {
  font-size: 13px;
  color: var(--color-text);
  margin-top: 4px;
}

.kd-landing-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.kd-landing-input {
  width: 100%;
  padding: 13px 18px;
  background: rgba(0, 0, 0, 0.38);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  color: #ffffff;
  font-size: 14px;
  outline: none;
  box-shadow: inset 0 1.5px 3px rgba(0, 0, 0, 0.4);
  transition: all 0.2s cubic-bezier(0.25, 1, 0.5, 1);
  box-sizing: border-box;
}

.kd-landing-input::placeholder {
  color: rgba(235, 235, 245, 0.4);
}

.kd-landing-input:focus {
  border-color: #0a84ff;
  box-shadow: inset 0 1.5px 3px rgba(0, 0, 0, 0.4), 0 0 0 3px rgba(10, 132, 255, 0.35);
}

/* iOS Segmented Control for Models */
.kd-model-group {
  display: flex;
  gap: 4px;
  width: 100%;
  background: rgba(118, 118, 128, 0.24);
  padding: 4px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.kd-model-btn {
  flex: 1;
  padding: 10px 8px;
  font-size: 13px;
  background: transparent;
  border: none;
  border-radius: 10px;
  color: rgba(235, 235, 245, 0.7);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  transition: all 0.2s cubic-bezier(0.25, 1, 0.5, 1);
}

.kd-model-btn:hover {
  color: #ffffff;
}

.kd-model-btn.active {
  background: rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3), 0 0 0 0.5px rgba(255, 255, 255, 0.18);
}

.kd-model-btn:active {
  transform: scale(0.97);
}

.kd-landing-submit {
  width: 100%;
  padding: 13px;
  font-size: 15px;
  font-weight: 600;
  background: #0a84ff;
  color: #ffffff;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(10, 132, 255, 0.38);
  transition: all 0.2s cubic-bezier(0.25, 1, 0.5, 1);
}

.kd-landing-submit:hover {
  background: #0071e3;
  box-shadow: 0 6px 22px rgba(10, 132, 255, 0.48);
}

.kd-landing-submit:active {
  transform: scale(0.98);
}

.kd-landing-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 6px;
}

.kd-landing-github-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.42);
  transition: all 0.25s cubic-bezier(0.25, 1, 0.5, 1);
  padding: 8px;
  border-radius: 50%;
  text-decoration: none;
}

.kd-landing-github-link:hover {
  color: #ffffff;
  transform: scale(1.15);
  background: rgba(255, 255, 255, 0.08);
}

/* ============================================================================
   Tier 2: Review Screen Header & Segmented Controls
   ============================================================================ */
.kd-tier2 {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.kd-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--apple-card-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: var(--apple-border);
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
  transition: background 0.3s ease, border-color 0.3s ease;
}

.kd-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 20px;
  gap: 14px;
}

.kd-header-top {
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.kd-header-bottom {
  background: rgba(0, 0, 0, 0.25);
  padding: 6px 20px;
}

.kd-step-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.kd-step-mid {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  max-width: 660px;
}

.kd-step-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.kd-step-group {
  display: inline-flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  overflow: hidden;
}

.kd-step-group .kd-step-btn {
  border: none;
  border-radius: 0;
  background: transparent;
  padding: 5px 11px;
}

.kd-step-group .kd-step-btn:not(:last-child) {
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.kd-step-group .kd-step-btn:hover {
  background: rgba(255, 255, 255, 0.14);
}

.kd-step-group .kd-step-btn.blunder {
  color: #ff453a;
  background: rgba(255, 69, 58, 0.10);
}

.kd-step-group .kd-step-btn.blunder:hover {
  background: rgba(255, 69, 58, 0.22);
}

.kd-step-btn {
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #ffffff;
  cursor: pointer;
  transition: all 0.18s ease;
  white-space: nowrap;
}
.kd-step-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.2);
}
.kd-step-btn.blunder {
  background: rgba(255, 69, 58, 0.15);
  color: #ff453a;
  border-color: rgba(255, 69, 58, 0.3);
}
.kd-step-btn.blunder:hover {
  background: rgba(255, 69, 58, 0.25);
}

.kd-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.kd-back-btn {
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  color: #ffffff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.18s ease;
}

.kd-back-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.2);
}

.kd-back-btn:active {
  transform: scale(0.96);
}

.kd-kyoku-select {
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  background: rgba(0, 0, 0, 0.35);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  outline: none;
  cursor: pointer;
  transition: all 0.18s ease;
}

.kd-kyoku-select:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.22);
}

.kd-kyoku-select option {
  background: #1c1c1e;
  color: #ffffff;
}

/* iOS Segmented Control for Seat Tabs */
.kd-seat-tabs {
  display: flex;
  background: rgba(118, 118, 128, 0.24);
  padding: 3px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  gap: 2px;
}

.kd-tab {
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 500;
  background: transparent;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  color: rgba(235, 235, 245, 0.7);
  transition: all 0.18s cubic-bezier(0.25, 1, 0.5, 1);
}

.kd-tab:hover {
  color: #ffffff;
}

.kd-tab.active {
  background: rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3), 0 0 0 0.5px rgba(255, 255, 255, 0.2);
}

.kd-tab:active {
  transform: scale(0.96);
}

.kd-seat-wind {
  color: rgba(255, 255, 255, 0.48);
  font-weight: 500;
  font-size: 0.9em;
  padding: 1px 5px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  margin-right: 5px;
  letter-spacing: 0.3px;
  transition: all 0.18s ease;
}

.kd-tab.active .kd-seat-wind {
  color: #ffcc00;
  background: rgba(255, 204, 0, 0.18);
  font-weight: 700;
}

.kd-seat-name {
  color: var(--color-text-bright);
  font-weight: 600;
}

.kd-header-mid {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  max-width: 420px;
}

.kd-play-btn {
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  background: #30d158;
  color: #ffffff;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(48, 209, 88, 0.3);
  transition: all 0.18s ease;
  white-space: nowrap;
}

.kd-play-btn:hover {
  background: #34c759;
  box-shadow: 0 3px 14px rgba(48, 209, 88, 0.4);
}

.kd-play-btn.playing {
  background: #ff9f0a;
  box-shadow: 0 2px 10px rgba(255, 159, 10, 0.35);
}

.kd-play-btn:active {
  transform: scale(0.96);
}

.kd-speed-select {
  padding: 5px 8px;
  font-size: 12px;
  font-weight: 700;
  font-family: ui-monospace, SFMono-Regular, "SF Pro Text", monospace;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 9px;
  cursor: pointer;
  outline: none;
  transition: all 0.18s ease;
  white-space: nowrap;
}

.kd-speed-select:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.32);
  color: #ffffff;
}

.kd-speed-select:focus {
  border-color: #0a84ff;
  box-shadow: 0 0 0 2px rgba(10, 132, 255, 0.35);
}

.kd-speed-select option {
  background: #1c1c1e;
  color: #ffffff;
}

.kd-step-counter {
  font-size: 13px;
  font-family: ui-monospace, SFMono-Regular, "SF Pro Text", monospace;
  font-variant-numeric: tabular-nums;
  color: #ffffff;
  min-width: 54px;
  text-align: center;
}

.kd-slider {
  flex: 1;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255, 255, 255, 0.16);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}

.kd-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  transition: transform 0.1s ease;
}

.kd-slider::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

.kd-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffffff;
  border: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  cursor: pointer;
}

.kd-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.kd-chip-btn {
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #ffffff;
  cursor: pointer;
  transition: all 0.18s ease;
}

.kd-chip-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.2);
}

.kd-chip-btn:active {
  transform: scale(0.96);
}

.kd-chip-btn.active {
  background: rgba(48, 209, 88, 0.16);
  border-color: rgba(48, 209, 88, 0.35);
  color: #30d158;
}

.kd-match-badge {
  font-size: 12px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
}

.kd-match-badge:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.28);
}

.kd-match-badge:active {
  transform: scale(0.97);
}

.kd-badge-match {
  color: #30d158; /* 翡翠绿：模型一致率 */
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.kd-badge-blunder {
  color: #ff453a; /* 醒目红：恶手 */
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.kd-badge-rating {
  color: #ffd60a; /* 金黄：Rating */
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.kd-badge-sep {
  color: rgba(255, 255, 255, 0.25);
  font-weight: 400;
  margin: 0 2px;
}

/* ============================================================================
   KillerDucky Outer Container & Mahjong Board Layout
   ============================================================================ */
.outer {
  margin: 20px auto 30px;
  display: flex;
  justify-content: center;
  gap: 20px;
  max-width: 1360px;
  width: 100%;
  padding: 0 16px;
}

.grid-main {
  flex-shrink: 0;
  display: grid;
  width: calc(var(--zoom) * 655px);
  height: calc(var(--zoom) * 735px);
  grid-template-columns: calc(90 / 655 * 100%) calc(135 / 655 * 100%) calc(205 / 655 * 100%) calc(135 / 655 * 100%) calc(90 / 655 * 100%);
  grid-template-rows: calc(90 / 735 * 100%) calc(135 / 735 * 100%) calc(205 / 735 * 100%) calc(135 / 735 * 100%) calc((90 + 70) / 735 * 100%);
  grid-template-areas:
    "ah-p2 ah-p2 ah-p2   ah-p2 ah-p1"
    "ah-p3 .     ad-p2   .     ah-p1"
    "ah-p3 ad-p3 a-info  ad-p1 ah-p1"
    "ah-p3 .     ad-p0   .     ah-p1"
    "ah-p3 ah-p0 ah-p0   ah-p0 ah-p0";
  position: relative;
  background: var(--color-table-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--color-table-border);
  border-radius: 20px;
  box-shadow: var(--color-table-shadow, 0 12px 40px rgba(0, 0, 0, 0.55)), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  overflow: hidden;
  transition: background 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.grid-hand {
  display: flex;
  background: rgba(28, 28, 30, 0.5);
  align-items: center;
  cursor: pointer;
  transition: background 0.18s ease;
}

.grid-hand:hover {
  background: rgba(44, 44, 46, 0.5);
}

.grid-hand-p3 {
  grid-area: ah-p3;
  flex-direction: column;
  justify-content: space-between;
  gap: 6px;
  padding-bottom: calc(var(--zoom) * 15px);
  padding-top: calc(var(--zoom) * 5px);
  padding-right: calc(var(--zoom) * 20px);
}

.grid-hand-p2 {
  grid-area: ah-p2;
  flex-flow: row-reverse;
  justify-content: space-between;
  gap: 6px;
  padding-left: calc(var(--zoom) * 15px);
  padding-right: calc(var(--zoom) * 5px);
  padding-bottom: calc(var(--zoom) * 20px);
}

.grid-hand-p1 {
  grid-area: ah-p1;
  flex-direction: column-reverse;
  justify-content: space-between;
  gap: 6px;
  padding-top: calc(var(--zoom) * 15px);
  padding-bottom: calc(var(--zoom) * 5px);
  padding-left: calc(var(--zoom) * 20px);
}

.grid-hand-p0-container {
  grid-area: ah-p0;
  background: rgba(28, 28, 30, 0.5);
  padding-top: calc(var(--zoom) * 6px);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  cursor: pointer;
}

.grid-hand-p0 {
  justify-content: space-between;
  gap: 10px;
  padding-left: calc(var(--zoom) * 5px);
  padding-right: calc(var(--zoom) * 15px);
}

.hand-calls-p0:empty,
.hand-calls-p1:empty,
.hand-calls-p2:empty,
.hand-calls-p3:empty {
  display: none !important;
}

.hand-closed-p3 { display: flex; flex-direction: column; }
.hand-closed-p2 { display: flex; flex-direction: row-reverse; }
.hand-closed-p1 { display: flex; flex-direction: column-reverse; }
.hand-closed-p0 { display: flex; flex-direction: row; }

.hand-calls-p3 { display: flex; flex-direction: column; gap: 4px; width: var(--tile-height); align-items: center; }
.hand-calls-p2 { display: flex; flex-direction: row-reverse; gap: 4px; }
.hand-calls-p1 { display: flex; flex-direction: column-reverse; gap: 4px; width: var(--tile-height); align-items: center; }
.hand-calls-p0 { display: flex; flex-direction: row; gap: 4px; }

/* Meld Blocks (Chi, Pon, Kan, Ankan) with Directional Flow */
.meld-block {
  display: flex;
  align-items: center;
  justify-content: center;
}
.pov-p0 .meld-block, .meld-block-bottom, .meld-block-p0 {
  flex-direction: row;
}
.pov-p2 .meld-block, .meld-block-top, .meld-block-p2 {
  flex-direction: row-reverse;
}
.pov-p1 .meld-block, .meld-block-right, .meld-block-p1 {
  flex-direction: column-reverse;
  width: var(--tile-height);
}
.pov-p3 .meld-block, .meld-block-left, .meld-block-p3 {
  flex-direction: column;
  width: var(--tile-height);
}

/* ============================================================================
   Tile Rendering & Transformations
   ============================================================================ */
.tileDiv {
  width: var(--tile-width);
  height: var(--tile-height);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.pov-p1 .tileDiv { width: var(--tile-height); height: var(--tile-width); }
.pov-p3 .tileDiv { width: var(--tile-height); height: var(--tile-width); }

.pov-p0 .tileDiv:has(.rotate), .pov-p0 .tileDiv.has-rotate { width: var(--tile-height); height: var(--tile-height); }
.pov-p1 .tileDiv:has(.rotate), .pov-p1 .tileDiv.has-rotate { width: var(--tile-height); height: var(--tile-height); }
.pov-p2 .tileDiv:has(.rotate), .pov-p2 .tileDiv.has-rotate { width: var(--tile-height); height: var(--tile-height); }
.pov-p3 .tileDiv:has(.rotate), .pov-p3 .tileDiv.has-rotate { width: var(--tile-height); height: var(--tile-height); }

.pov-p0 .narrow { width: calc(0.5 * var(--tile-width)); }
.pov-p1 .narrow { height: calc(0.5 * var(--tile-width)); }
.pov-p2 .narrow { width: calc(0.5 * var(--tile-width)); }
.pov-p3 .narrow { height: calc(0.5 * var(--tile-width)); }

.tileImg {
  width: calc(var(--tile-img-width));
  height: calc(var(--tile-img-height));
  background: linear-gradient(180deg, #ffffff 0%, #f6f5f1 100%);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.95), 0 1px 3px rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-sizing: border-box;
  padding: 2px;
  border-radius: calc(var(--zoom-tiles) * 4px);
  display: block;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  pointer-events: none;
  -webkit-user-drag: none;
  user-select: none;
}

.tileImg[src*="back"], img[src*="back"].tileImg {
  background: none !important;
  border: none !important;
  padding: 0 !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4) !important;
}

.tileImgHighlight {
  box-shadow: 0 0 0 calc(var(--zoom-tiles) * 2px) #0a84ff, inset 0 0 0 calc(var(--zoom-tiles) * 2px) #0a84ff !important;
  transform: translateY(-2px);
}

.tsumogiri {
  background: var(--color-tsumogiri) !important;
  filter: brightness(var(--brightness-tsumogiri)) saturate(80%) !important;
}

.called {
  opacity: var(--opacity-called);
}

.pov-p0 .tileDiv > .rotate, .pov-p0 > div > .rotate { transform-origin: center center; transform: rotate(90deg); }
.pov-p0 .tileDiv > .float, .pov-p0 > div > .float { transform-origin: bottom left; transform: rotate(90deg) translate(calc(-2 * var(--tile-width)), var(--tile-height)); }
.pov-p1 .tileDiv > img, .pov-p1 > div > img { transform-origin: center center; transform: rotate(-90deg); }
.pov-p1 .tileDiv > .rotate, .pov-p1 > div > .rotate { transform-origin: center center; transform: rotate(0deg); }
.pov-p1 .tileDiv > .float, .pov-p1 > div > .float { transform: translate(calc(-1 * var(--tile-width)), 0px); }
.pov-p2 .tileDiv > img, .pov-p2 > div > img { transform: center center; transform: rotate(180deg); }
.pov-p2 .tileDiv > .rotate, .pov-p2 > div > .rotate { transform-origin: center center; transform: rotate(-90deg); }
.pov-p2 .tileDiv > .float, .pov-p2 > div > .float { transform-origin: top left; transform: rotate(-90deg) translate(calc(-2 * var(--tile-width)), 0px); }
.pov-p3 .tileDiv > img, .pov-p3 > div > img { transform-origin: center center; transform: rotate(90deg); }
.pov-p3 .tileDiv > .rotate, .pov-p3 > div > .rotate { transform-origin: center center; transform: rotate(0deg); }
.pov-p3 .tileDiv > .float, .pov-p3 > div > .float { transform: translate(var(--tile-width), calc(-1 * var(--tile-height))); }

.tileImg.last-discard,
.tileDiv.has-last-discard .tileImg {
  box-shadow: 0 0 0 2px #30d158, 0 2px 8px rgba(48, 209, 88, 0.45);
  border-radius: 3px;
}

/* ============================================================================
   Discard Ponds (Rivers) — Strictly 6 tiles per row, exactly 3 rows
   Strict baseline lock to prevent any float jump on called/tsumogiri
   ============================================================================ */
.river-row {
  display: flex;
}

.grid-discard-p0 {
  grid-area: ad-p0;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: flex-start;
}
.grid-discard-p0 .river-row {
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  height: var(--tile-height);
}

.grid-discard-p1 {
  grid-area: ad-p1;
  display: flex;
  flex-direction: row;
  align-self: end;
  align-items: flex-end;
  justify-content: flex-start;
}
.grid-discard-p1 .river-row {
  display: flex;
  flex-direction: column-reverse;
  justify-content: flex-start;
  align-items: flex-end;
  width: var(--tile-height);
}

.grid-discard-p2 {
  grid-area: ad-p2;
  display: flex;
  flex-direction: column-reverse;
  justify-content: flex-start;
  align-items: flex-end;
}
.grid-discard-p2 .river-row {
  display: flex;
  flex-direction: row-reverse;
  justify-content: flex-start;
  align-items: flex-end;
  height: var(--tile-height);
}

.grid-discard-p3 {
  grid-area: ad-p3;
  display: flex;
  flex-direction: row-reverse;
  align-items: flex-start;
  justify-content: flex-start;
}
.grid-discard-p3 .river-row {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: flex-start;
  width: var(--tile-height);
}

/* ============================================================================
   Center Info Box (Apple Frosted Glass HIG finish)
   ============================================================================ */
.grid-info {
  width: calc(var(--zoom) * 200px);
  height: calc(var(--zoom) * 200px);
  grid-area: a-info;
  display: grid;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 16px;
  margin: auto;
  grid-template-columns: 12% 1% 74% 1% 12%;
  grid-template-rows: repeat(5, 1fr);
  grid-template-areas:
    "ai-p3 ai-p2 ai-p2   ai-p2 ai-p2"
    "ai-p3 .    ai-round   .     ai-p1"
    "ai-p3 .    ai-tiles   .     ai-p1"
    "ai-p3 .    ai-doras   .     ai-p1"
    "ai-p0 ai-p0 ai-p0   ai-p0 ai-p1";
  background: var(--apple-card-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--color-table-border);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.12), 0 8px 24px rgba(0, 0, 0, 0.45);
  overflow: hidden;
  transition: background 0.3s ease, border-color 0.3s ease;
}

.info-round {
  grid-area: ai-round;
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  cursor: pointer;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 3px 5px !important;
  gap: 2px !important;
  transition: all 0.18s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

.info-round-title {
  font-size: 13.5px;
  font-weight: 800;
  line-height: 1.2;
  color: #ffffff;
}

.info-round-title.only {
  font-size: 15px;
}

.info-round-sub {
  display: flex;
  align-items: center;
  gap: 4px;
  line-height: 1;
}

.info-tag-honba {
  background: rgba(255, 255, 255, 0.12);
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 600;
  color: rgba(235, 235, 245, 0.9);
}

.info-tag-kyotaku {
  background: rgba(255, 69, 58, 0.16);
  border: 1px solid rgba(255, 69, 58, 0.35);
  color: #ff6961;
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-family: ui-monospace, SFMono-Regular, monospace;
}

.riichi-stick-mini {
  width: 10px;
  height: 3px;
  background: #ffffff;
  border-radius: 1px;
  display: inline-block;
  position: relative;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.riichi-stick-mini::after {
  content: "";
  width: 3px;
  height: 3px;
  background: #ff453a;
  border-radius: 50%;
  position: absolute;
  left: 3.5px;
  top: 0;
}

.info-round:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.25);
}

.info-round:active {
  transform: scale(0.96);
}

.info-tiles-left {
  grid-area: ai-tiles;
  margin: auto;
  font-size: 14px;
  font-weight: 600;
  color: #ffffff;
}

.info-doras {
  grid-area: ai-doras;
  display: flex;
  margin: auto;
  gap: 2.5px;
  align-items: center;
  justify-content: center;
}

.info-doras > * > * {
  width: calc(var(--tile-img-width) * 0.77);
  height: calc(var(--tile-img-height) * 0.77);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
}

.info-doras > * {
  width: calc(var(--tile-img-width) * 0.77 + 2px);
  height: calc(var(--tile-img-height) * 0.77 + 2px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.gi-p0-outer, .gi-p1-outer, .gi-p2-outer, .gi-p3-outer {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 500;
  color: rgba(235, 235, 245, 0.75);
}

.gi-p0-outer {
  grid-area: ai-p0;
  margin: auto calc(var(--zoom) * 10px);
}

.gi-p1-outer {
  grid-area: ai-p1;
  writing-mode: vertical-rl;
  text-orientation: sideways;
  transform: rotate(180deg);
  margin: calc(var(--zoom) * 10px) auto;
}

.gi-p2-outer {
  grid-area: ai-p2;
  transform: rotate(180deg);
  margin: auto calc(var(--zoom) * 10px);
}

.gi-p3-outer {
  grid-area: ai-p3;
  writing-mode: vertical-rl;
  text-orientation: sideways;
  margin: calc(var(--zoom) * 10px) auto;
}

.gi-wind {
  color: rgba(255, 255, 255, 0.45);
  font-weight: 500;
  margin-right: 4px;
}

.gi-score {
  color: #ffffff;
  font-weight: 700;
  letter-spacing: 0.5px;
}

/* ============================================================================
   Mortal Discard Bars SVG (Apple Green Bars)
   ============================================================================ */
.discard-bars {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: calc(var(--zoom-tiles) * 50px) 0;
  height: 50px;
  position: relative;
}

.discard-bars-svg {
  width: 100%;
  height: 50px;
}

/* ============================================================================
   Right Sidebar (Controls, Decision Details, Shortcuts) — Apple Cards
   ============================================================================ */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 350px;
  height: calc(var(--zoom) * 735px);
  box-sizing: border-box;
  flex-shrink: 0;
}

.controls {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  padding: 8px;
  background: var(--apple-card-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: var(--apple-border);
  border-radius: 16px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
  gap: 6px;
  flex-shrink: 0;
  transition: background 0.3s ease, border-color 0.3s ease;
}

.controls > * {
  padding: 7px 6px;
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.18s cubic-bezier(0.25, 1, 0.5, 1);
}

.controls > *:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.2);
}

.controls > *:active {
  transform: scale(0.96);
  background: rgba(255, 255, 255, 0.22);
}

/* Active Decision Details Card — Apple HIG Design */
.kd-decision-card {
  background: var(--apple-card-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: var(--apple-border);
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
  border-radius: 18px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  box-sizing: border-box;
  transition: opacity 0.15s ease, background 0.3s ease, border-color 0.3s ease;
}

.kd-decision-card::-webkit-scrollbar {
  width: 5px;
}

.kd-decision-card::-webkit-scrollbar-track {
  background: transparent;
}

.kd-decision-card::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

.kd-decision-card::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.35);
}

.kd-decision-card.is-idle {
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
}

.kd-dec-header {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 10px;
}

.kd-decision-card.is-idle .kd-dec-header,
.kd-dec-header:has(.kd-dec-verdict.is-empty),
.kd-dec-header:empty {
  display: none !important;
  border-bottom: none !important;
}

.kd-dec-turn-title {
  display: none !important;
}

.kd-dec-verdict {
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
}

.kd-dec-verdict.best {
  background: rgba(48, 209, 88, 0.18);
  color: #30d158;
  border: 1px solid rgba(48, 209, 88, 0.35);
}

.kd-dec-verdict.blunder {
  background: rgba(255, 69, 58, 0.18);
  color: #ff453a;
  border: 1px solid rgba(255, 69, 58, 0.35);
}

.kd-dec-verdict.question {
  background: rgba(255, 159, 10, 0.18);
  color: #ff9f0a;
  border: 1px solid rgba(255, 159, 10, 0.35);
}

.kd-dec-verdict.cruise {
  background: rgba(10, 132, 255, 0.18);
  color: #0a84ff;
  border: 1px solid rgba(10, 132, 255, 0.35);
}

.kd-dec-verdict.agari {
  font-size: 16px;
  font-weight: 800;
  padding: 6px 16px;
  letter-spacing: 0.5px;
  border-radius: 20px;
  background: rgba(255, 214, 10, 0.22);
  color: #ffd60a;
  border: 1px solid rgba(255, 214, 10, 0.5);
  box-shadow: 0 4px 12px rgba(255, 214, 10, 0.25);
}

.kd-dec-verdict.round-end {
  font-size: 16px;
  font-weight: 800;
  padding: 6px 16px;
  letter-spacing: 0.5px;
  border-radius: 20px;
}

.kd-dec-verdict.round-end.best {
  background: rgba(48, 209, 88, 0.22);
  color: #30d158;
  border: 1px solid rgba(48, 209, 88, 0.5);
  box-shadow: 0 4px 12px rgba(48, 209, 88, 0.25);
}

.kd-dec-verdict.round-end.blunder {
  background: rgba(255, 69, 58, 0.22);
  color: #ff453a;
  border: 1px solid rgba(255, 69, 58, 0.5);
  box-shadow: 0 4px 12px rgba(255, 69, 58, 0.25);
}

.kd-dec-verdict.round-end.agari {
  background: rgba(255, 214, 10, 0.22);
  color: #ffd60a;
  border: 1px solid rgba(255, 214, 10, 0.5);
  box-shadow: 0 4px 12px rgba(255, 214, 10, 0.25);
}

.kd-dec-verdict.round-end.cruise {
  background: rgba(10, 132, 255, 0.22);
  color: #0a84ff;
  border: 1px solid rgba(10, 132, 255, 0.5);
  box-shadow: 0 4px 12px rgba(10, 132, 255, 0.25);
}

/* Winning Agari Tile Highlight */
.tileDiv.agari-tile,
.tileDiv:has(.agari-tile) {
  position: relative;
}
.tileImg.agari-tile {
  box-shadow: 0 0 0 2.5px #ffd60a, 0 0 12px rgba(255, 214, 10, 0.8) !important;
  transform: translateY(-3px) scale(1.05);
}

/* Ronned Discard in Loser's River */
.tileImg.ron-claimed {
  box-shadow: 0 0 0 2.5px #ff453a, 0 0 12px rgba(255, 69, 58, 0.8) !important;
  filter: brightness(110%) !important;
  opacity: 1 !important;
}

/* Dynamic Step Action Desc Pill */
.kd-step-dynamic-desc {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-bright);
  background: rgba(255, 255, 255, 0.06);
  padding: 6px 10px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  border-left: 3px solid #0a84ff;
}
.kd-step-dynamic-desc.is-hora {
  border-left-color: #ffd60a;
  background: rgba(255, 214, 10, 0.12);
  color: #ffd60a;
}
.kd-step-dynamic-desc.is-ryuukyoku {
  border-left-color: #ff9f0a;
  background: rgba(255, 159, 10, 0.12);
  color: #ff9f0a;
}

/* Standalone Settlement Banner & Container (Round-End Settlement Card) */
.kd-settlement-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  box-sizing: border-box;
  margin-bottom: 8px;
}

.kd-settlement-banner {
  background: linear-gradient(135deg, rgba(255, 214, 10, 0.12), rgba(255, 159, 10, 0.05));
  border: 1px solid rgba(255, 214, 10, 0.35);
  border-radius: 14px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
}

.kd-settlement-banner.is-hero-win {
  background: linear-gradient(135deg, rgba(48, 209, 88, 0.18), rgba(48, 209, 88, 0.06));
  border-color: rgba(48, 209, 88, 0.45);
}

.kd-settlement-banner.is-hero-blunder {
  background: linear-gradient(135deg, rgba(255, 69, 58, 0.18), rgba(255, 69, 58, 0.06));
  border-color: rgba(255, 69, 58, 0.45);
}

.kd-settlement-banner.is-ryuukyoku {
  background: linear-gradient(135deg, rgba(255, 214, 10, 0.14), rgba(255, 159, 10, 0.05));
  border: 1px solid rgba(255, 214, 10, 0.35);
  padding: 12px 14px;
}

.kd-settlement-ryuukyoku-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: rgba(255, 214, 10, 0.14);
  border: 1px solid rgba(255, 214, 10, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: #ffd60a;
  flex-shrink: 0;
}

.kd-settlement-ryuukyoku-subtag {
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(235, 235, 245, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.12);
  display: inline-block;
  margin-left: 6px;
}

.kd-settlement-kyotaku-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 159, 10, 0.08);
  border: 1px solid rgba(255, 159, 10, 0.28);
  border-radius: 8px;
  padding: 7px 12px;
  margin-top: 8px;
  box-sizing: border-box;
  width: 100%;
}

.kd-kyotaku-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 159, 10, 0.16);
  border: 1px solid rgba(255, 159, 10, 0.35);
  padding: 3px 8px;
  border-radius: 5px;
  white-space: nowrap;
}

.kd-kyotaku-tag {
  font-size: 11px;
  font-weight: 700;
  color: #ff9f0a;
  letter-spacing: 0.5px;
}

.kd-kyotaku-pts {
  font-size: 13.5px;
  font-weight: 800;
  color: #ffffff;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.5px;
}

.kd-kyotaku-desc {
  font-size: 11px;
  color: rgba(235, 235, 245, 0.6);
  white-space: nowrap;
}

.kd-dec-verdict.is-empty {
  display: none !important;
}

.kd-ryuukyoku-status-tag {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  margin-left: 6px;
  display: inline-block;
  line-height: 1.3;
}
.kd-ryuukyoku-status-tag.tenpai {
  background: rgba(48, 209, 88, 0.18);
  color: #30d158;
  border: 1px solid rgba(48, 209, 88, 0.35);
}
.kd-ryuukyoku-status-tag.noten {
  background: rgba(255, 69, 58, 0.15);
  color: #ff6961;
  border: 1px solid rgba(255, 69, 58, 0.3);
}
.kd-ryuukyoku-status-tag.neutral {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(235, 235, 245, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.kd-settlement-banner-top {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.kd-settlement-agari-tile-wrap {
  width: 42px;
  height: 56px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #ffffff 0%, #f6f5f1 100%);
  border-radius: 6px;
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.95), 0 3px 8px rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(0, 0, 0, 0.1);
  padding: 3px;
  box-sizing: border-box;
}

.kd-settlement-agari-tile-wrap img {
  width: 100%;
  height: 100%;
  display: block;
}

.kd-settlement-banner-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1;
}

.kd-settlement-winner-title {
  font-size: 14px;
  font-weight: 800;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.kd-settlement-player-highlight {
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kd-settlement-player-highlight.winner {
  color: #ffffff;
  text-shadow: 0 0 12px rgba(255, 255, 255, 0.4);
}

.kd-settlement-player-highlight.loser {
  color: #ff9f0a;
  text-shadow: 0 0 8px rgba(255, 159, 10, 0.3);
}

.kd-settlement-seat-wind {
  color: rgba(235, 235, 245, 0.65);
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}

.kd-settlement-win-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1.2;
  flex-shrink: 0;
}

.kd-settlement-win-badge.ron {
  background: rgba(112, 215, 255, 0.15);
  color: #70d7ff;
  border: 1px solid rgba(112, 215, 255, 0.3);
}

.kd-settlement-win-badge.tsumo {
  background: rgba(48, 209, 88, 0.15);
  color: #30d158;
  border: 1px solid rgba(48, 209, 88, 0.3);
}

.kd-settlement-score-tag {
  font-size: 18px;
  font-weight: 900;
  font-family: ui-monospace, SFMono-Regular, "SF Pro Text", monospace;
  color: #30d158;
  text-shadow: 0 0 14px rgba(48, 209, 88, 0.5);
  white-space: nowrap;
  letter-spacing: -0.5px;
}

.kd-settlement-score-tag.neg {
  color: #ff453a;
  text-shadow: 0 0 14px rgba(255, 69, 58, 0.5);
}

.kd-settlement-details-box {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 8px;
  padding: 8px 10px;
}

.kd-settlement-loser-line {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.kd-settlement-loser-action {
  color: #ff453a;
  font-weight: 700;
  flex-shrink: 0;
}

.kd-settlement-loser-points {
  color: #ff453a;
  font-weight: 800;
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 12px;
  margin-left: auto;
}

.kd-settlement-tsumo-action {
  color: #30d158;
  font-weight: 700;
  font-size: 12px;
}

.kd-settlement-uradora-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.kd-settlement-uradora-label {
  font-size: 11px;
  font-weight: 700;
  color: rgba(235, 235, 245, 0.7);
  flex-shrink: 0;
}

.kd-settlement-uradora-tiles {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.kd-settlement-uradora-tile {
  width: 20px;
  height: 27px;
  border-radius: 3px;
  display: block;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  background: #f2f2f7;
}

.kd-settlement-yaku-text {
  font-size: 12px;
  color: rgba(235, 235, 245, 0.8);
  line-height: 1.45;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 8px;
}

/* Settlement Card Container */
.kd-settlement-card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 214, 10, 0.3);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.kd-settlement-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 800;
  font-size: 14px;
  color: #ffd60a;
}
.kd-settlement-summary-text {
  font-size: 13px;
  line-height: 1.4;
  color: #ffffff;
}

/* 2x2 Clean Player Delta Grid */
.kd-settlement-delta-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  width: 100%;
  box-sizing: border-box;
}
.kd-settlement-delta-cell {
  background: rgba(0, 0, 0, 0.32);
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid rgba(255, 255, 255, 0.08);
  min-width: 0;
  box-sizing: border-box;
}
.kd-settlement-delta-cell.winner {
  border-color: rgba(48, 209, 88, 0.45);
  background: rgba(48, 209, 88, 0.12);
}
.kd-settlement-delta-cell.loser {
  border-color: rgba(255, 69, 58, 0.45);
  background: rgba(255, 69, 58, 0.12);
}
.kd-settlement-player-name {
  font-size: 12px;
  color: var(--color-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 140px;
  flex: 1;
}
.kd-settlement-score-diff {
  font-size: 13px;
  font-weight: 700;
  font-family: ui-monospace, monospace;
}
.kd-settlement-score-diff.pos {
  color: #30d158;
}
.kd-settlement-score-diff.neg {
  color: #ff453a;
}
.kd-settlement-score-diff.zero {
  color: var(--color-text-secondary);
}

/* Vertical Decision Comparison Cards */
.kd-hero-compare-vertical {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.kd-choice-block {
  border-radius: 12px;
  padding: 8px 14px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 16px;
}

.kd-choice-ai {
  border-left: 4px solid #30d158;
  background: linear-gradient(90deg, rgba(48, 209, 88, 0.12) 0%, rgba(0, 0, 0, 0.28) 100%);
}

.kd-choice-actual {
  border-left: 4px solid #0a84ff;
  background: linear-gradient(90deg, rgba(10, 132, 255, 0.10) 0%, rgba(0, 0, 0, 0.28) 100%);
}

.kd-choice-actual.is-blunder {
  border-left-color: #ff453a;
  background: linear-gradient(90deg, rgba(255, 69, 58, 0.14) 0%, rgba(0, 0, 0, 0.28) 100%);
}

.kd-choice-badge-label {
  font-size: 14px;
  font-weight: 700;
  color: rgba(235, 235, 245, 0.85);
  letter-spacing: 0.5px;
  margin-bottom: 0;
  width: 52px;
  flex-shrink: 0;
}

.kd-choice-content {
  display: flex;
  align-items: center;
  justify-content: center;
}

.kd-choice-tile-wrap {
  width: 44px;
  height: 58px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #ffffff 0%, #f6f5f1 100%);
  border-radius: 6px;
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.95), 0 3px 8px rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(0, 0, 0, 0.1);
  padding: 3px;
  box-sizing: border-box;
}

.kd-choice-tile-wrap img {
  width: 100%;
  height: 100%;
  display: block;
}

.kd-choice-tile-wrap:has(.action-badge),
.kd-choice-tile-wrap.has-action-badge {
  background: transparent !important;
  box-shadow: none !important;
  border: none !important;
  padding: 0 !important;
  width: auto !important;
  height: auto !important;
  min-width: unset !important;
}

.kd-choice-tile-wrap:has(img.rotate),
.kd-choice-tile-wrap.has-rotate {
  width: 58px !important;
  height: 44px !important;
}

.kd-choice-tile-wrap.has-rotate img,
.kd-choice-tile-wrap img.rotate,
.kd-cand-tile-img.rotate {
  transform: rotate(90deg);
  transform-origin: center center;
}

.kd-choice-meta {
  display: none !important;
}

.kd-tag-prob {
  font-size: 12px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  background: #30d158;
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(48, 209, 88, 0.3);
}

.kd-tag-shanten, .kd-tag-ukeire {
  font-size: 11px;
  font-weight: 500;
  padding: 3px 7px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.kd-tag-verdict {
  font-size: 12px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  color: #ffffff;
}

.kd-tag-verdict.best {
  background: rgba(48, 209, 88, 0.25);
  color: #30d158;
  border: 1px solid rgba(48, 209, 88, 0.4);
}

.kd-tag-verdict.blunder {
  background: rgba(255, 69, 58, 0.25);
  color: #ff453a;
  border: 1px solid rgba(255, 69, 58, 0.4);
}

.kd-tag-verdict.question {
  background: rgba(255, 159, 10, 0.25);
  color: #ff9f0a;
  border: 1px solid rgba(255, 159, 10, 0.4);
}

.kd-cand-section-title,
#decCandTitle {
  display: none !important;
}

.kd-cand-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.25);
  box-sizing: border-box;
}

.kd-cand-table th, .kd-cand-table td {
  padding: 6px 4px;
  text-align: center;
  vertical-align: middle;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  box-sizing: border-box;
}

.kd-cand-table th {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(235, 235, 245, 0.75);
  font-size: 11px;
  font-weight: 600;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.kd-cand-table th:nth-child(1) { width: 48px; text-align: center; }
.kd-cand-table th:nth-child(2) { width: 64px; text-align: center; }
.kd-cand-table th:nth-child(3) { width: 80px; text-align: center; }
.kd-cand-table th:nth-child(4) { width: 66px; text-align: center; }
.kd-cand-table th:nth-child(5) { width: 72px; text-align: center; }

.kd-cand-table tr:last-child td {
  border-bottom: none;
}

.kd-cand-action {
  display: inline-block;
  padding: 2px 4px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.10);
  color: rgba(235, 235, 245, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.12);
  letter-spacing: 0.5px;
  min-width: 24px;
  text-align: center;
  line-height: 1.3;
}

.kd-cand-action.action-chi {
  background: rgba(112, 215, 255, 0.18);
  color: #70d7ff;
  border-color: rgba(112, 215, 255, 0.4);
}

.kd-cand-action.action-pon {
  background: rgba(255, 179, 64, 0.18);
  color: #ffb340;
  border-color: rgba(255, 179, 64, 0.4);
}

.kd-cand-action.action-kan {
  background: rgba(218, 143, 255, 0.18);
  color: #da8fff;
  border-color: rgba(218, 143, 255, 0.4);
}

.kd-cand-action.action-hora {
  background: rgba(48, 209, 88, 0.22);
  color: #30d158;
  border-color: rgba(48, 209, 88, 0.5);
}

.kd-cand-action.action-riichi {
  background: rgba(255, 69, 58, 0.18);
  color: #ff453a;
  border-color: rgba(255, 69, 58, 0.4);
}

.kd-cand-action.action-dahai {
  background: rgba(255, 255, 255, 0.10);
  color: rgba(235, 235, 245, 0.9);
  border-color: rgba(255, 255, 255, 0.15);
}

.kd-cand-action.action-pass {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(235, 235, 245, 0.75);
  border-color: rgba(255, 255, 255, 0.14);
}

.kd-cand-tile-combo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.kd-cand-tile-combo .kd-cand-tile-img {
  width: 20px;
  height: 27px;
  padding: 1px;
}

.kd-cand-pass-text {
  display: inline-block;
  color: rgba(235, 235, 245, 0.65);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.kd-cand-tile-img {
  width: 28px;
  height: 38px;
  background: linear-gradient(180deg, #ffffff 0%, #f6f5f1 100%);
  border-radius: 4px;
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.95), 0 1px 3px rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(0, 0, 0, 0.08);
  padding: 2px;
  box-sizing: border-box;
  display: inline-block;
  vertical-align: middle;
}

.kd-cand-row {
  cursor: pointer;
  transition: background 0.15s ease;
}
.kd-cand-row:hover {
  background: rgba(255, 255, 255, 0.06);
}

.kd-ukeire-cell {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s ease;
}
.kd-cand-row:hover .kd-ukeire-cell {
  background: rgba(255, 255, 255, 0.1);
}
.kd-ukeire-arrow {
  font-size: 8px;
  opacity: 0.6;
  transition: transform 0.2s ease;
}
.kd-cand-row.is-expanded .kd-ukeire-arrow {
  transform: rotate(180deg);
}

/* Ukeire Detail Drawer */
.kd-cand-detail-row {
  transition: all 0.2s ease;
}
.kd-cand-detail-row.hidden {
  display: none !important;
}

.kd-cand-detail-row td {
  box-sizing: border-box;
  width: 100% !important;
  padding: 4px 8px 8px !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(0, 0, 0, 0.22);
}

.kd-ukeire-container {
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  padding: 6px 8px;
  background: rgba(18, 18, 20, 0.85);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.4);
}

.kd-ukeire-grid {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  box-sizing: border-box;
  width: 100%;
}

.kd-ukeire-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.07);
  padding: 2px 6px 2px 3px;
  border-radius: 5px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.kd-ukeire-img {
  width: 20px;
  height: 27px;
  background: linear-gradient(180deg, #ffffff 0%, #f6f5f1 100%);
  border-radius: 3px;
  padding: 1.5px;
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.95), 0 1px 2px rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-sizing: border-box;
  display: block;
}

.kd-ukeire-mul {
  font-size: 11px;
  font-weight: 700;
  color: #30d158;
  letter-spacing: 0.3px;
}

/* Secondary Right Column (Shortcuts Card & Appearance) */
.sidebar-secondary {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 270px;
  flex-shrink: 0;
}

/* Extracted Keyboard Shortcuts Card */
.kd-shortcuts-card {
  background: var(--apple-card-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: var(--apple-border);
  border-radius: 16px;
  padding: 14px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
  transition: background 0.3s ease, border-color 0.3s ease;
}

/* Non-Discard & Meld Action Badges (Pure Typography, Apple HIG Finish, No Fake Tile Box) */
.action-badge {
  width: auto !important;
  height: auto !important;
  min-width: unset !important;
  border-radius: 0 !important;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  background: transparent !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  border: none !important;
  box-shadow: none !important;
  padding: 2px 0;
  flex-shrink: 0;
  user-select: none;
}

.action-badge-text {
  font-size: calc(var(--zoom) * 18px + 2px);
  font-weight: 800;
  letter-spacing: 0.5px;
  line-height: 1.1;
  text-align: center;
}

/* Specific Action Flavors - Pure Vibrant Bold Typography, No Box */
.action-badge-pass {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  color: #30d158 !important;
}

.action-badge-chi {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  color: #70d7ff !important;
}

.action-badge-pon {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  color: #ffb340 !important;
}

.action-badge-kan {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  color: #da8fff !important;
}

.action-badge-riichi {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  color: #ff453a !important;
}

.action-badge-hora {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  color: #30d158 !important;
}

/* Table Score Diff Cell Highlights */
.score-pos {
  color: #30d158 !important;
}
.score-neg {
  color: #ff453a !important;
}
.score-zero {
  color: rgba(235, 235, 245, 0.5) !important;
}
.info-round-table tr.active-row td {
  background: rgba(10, 132, 255, 0.18) !important;
  border-left: 2px solid #0a84ff;
}

.kd-shortcuts-title {
  font-size: 13px;
  font-weight: 700;
  color: #ffffff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 8px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 7px;
}

.kd-shortcuts-table {
  width: 100%;
  border-collapse: collapse;
}

.kd-shortcuts-table tr {
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.kd-shortcuts-table tr:last-child {
  border-bottom: none;
}

.kd-shortcuts-table td {
  padding: 6px 2px;
}

.kd-shortcuts-keys {
  width: 82px;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 4px;
}

.kd-shortcuts-desc {
  font-size: 12px;
  color: rgba(235, 235, 245, 0.85);
  font-weight: 500;
  padding-left: 6px;
}

/* Apple Chiclet Keyboard Keycap */
.kd-kbd {
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.14) 0%, rgba(255, 255, 255, 0.06) 100%);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-bottom: 2px solid rgba(255, 255, 255, 0.28);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  border-radius: 5px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "SF Pro Text", sans-serif;
  font-size: 11.5px;
  font-weight: 700;
  color: #ffffff;
  box-sizing: border-box;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.5);
  user-select: none;
}

.kd-kbd.kd-kbd-wide {
  min-width: 44px;
  padding: 0 8px;
  font-size: 11px;
}

.kd-kbd-icon {
  width: 12px;
  height: 12px;
  stroke: currentColor;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  display: block;
}

code {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, "SF Pro Text", monospace;
  font-weight: 600;
  font-size: 11px;
  padding: 2px 7px;
  color: #ffffff;
  display: inline-block;
}

/* ============================================================================
   Modals (Apple Sheet Modal Style)
   ============================================================================ */
.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(32, 32, 36, 0.88);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 20px;
  color: #ffffff;
  padding: 24px;
  z-index: 1000;
  max-width: 620px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.1) inset;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 999;
}

.close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.8);
  border: none;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.18s ease;
}

.close:hover {
  background: rgba(255, 255, 255, 0.22);
  color: #ffffff;
}

#roundModal {
  max-width: 1120px;
  width: 96%;
  max-height: 90vh;
}

.round-modal-pov-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.round-modal-pov-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  padding: 5px 12px;
  color: rgba(235, 235, 245, 0.85);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.16s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.round-modal-pov-btn:hover {
  background: rgba(255, 255, 255, 0.16);
  color: #ffffff;
}

.round-modal-pov-btn.active {
  background: #0a84ff;
  border-color: #0a84ff;
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(10, 132, 255, 0.4);
}

.info-round-table {
  overflow-x: auto;
  max-height: calc(85vh - 140px);
  overflow-y: auto;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.25);
  margin-top: 10px;
}

.info-round-table table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12px;
  white-space: nowrap;
}

.info-round-table th, .info-round-table td {
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  padding: 8px 10px;
  vertical-align: middle;
}

.info-round-table th {
  background: #232328;
  text-align: center;
  color: rgba(235, 235, 245, 0.9);
  font-weight: 600;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
  position: sticky;
  top: 0;
  z-index: 5;
}

.info-round-table tbody tr:hover td {
  background: rgba(255, 255, 255, 0.07);
  cursor: pointer;
}

.info-round-table tbody tr.active-kyoku-row td {
  background: rgba(10, 132, 255, 0.16) !important;
}

.info-round-table tbody tr.active-kyoku-row td:first-child {
  border-left: 3px solid #0a84ff;
}

.info-round-table tfoot td {
  background: #1c1c20;
  border-top: 2px solid rgba(255, 255, 255, 0.2);
  border-bottom: none;
  font-weight: bold;
  position: sticky;
  bottom: 0;
  z-index: 5;
}

.active-pov-th {
  background: rgba(10, 132, 255, 0.25) !important;
  color: #70d7ff !important;
  border-left: 1px solid rgba(10, 132, 255, 0.4);
  border-right: 1px solid rgba(10, 132, 255, 0.4);
}

.active-pov-td {
  background: rgba(10, 132, 255, 0.08);
  border-left: 1px solid rgba(10, 132, 255, 0.2);
  border-right: 1px solid rgba(10, 132, 255, 0.2);
}

.score-num {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--color-text-bright);
}

.delta-badge {
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 4px;
  margin-left: 4px;
}

.delta-plus {
  color: #30d158;
}

.delta-minus {
  color: #ff453a;
}

.delta-zero {
  color: rgba(235, 235, 245, 0.4);
}

.blunder-badge-num {
  display: inline-block;
  min-width: 20px;
  text-align: center;
  padding: 1px 6px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 11px;
}

.blunder-badge-num.has-blunder {
  background: rgba(255, 69, 58, 0.25);
  color: #ff453a;
  border: 1px solid rgba(255, 69, 58, 0.45);
}

.blunder-badge-num.zero {
  color: rgba(235, 235, 245, 0.35);
}

#engineSelect {
  width: 100%;
  margin-top: 6px;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.38);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  color: #ffffff;
  outline: none;
  font-size: 13px;
}

#engineSelect option {
  background: #1c1c1e;
  color: #ffffff;
}

/* Toast */
.kd-toast-wrap {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 2000;
  pointer-events: none;
}

.kd-toast {
  padding: 10px 20px;
  background: rgba(36, 36, 38, 0.88);
  backdrop-filter: blur(25px);
  -webkit-backdrop-filter: blur(25px);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.5);
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.kd-toast.error {
  border-left: 4px solid #ff453a;
}

.kd-toast.success {
  border-left: 4px solid #30d158;
}

/* Loading Overlay */
.kd-loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(25px);
  -webkit-backdrop-filter: blur(25px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 1500;
  color: #ffffff;
}

.kd-spinner {
  width: 44px;
  height: 44px;
  border: 3.5px solid rgba(255, 255, 255, 0.15);
  border-top-color: #0a84ff;
  border-radius: 50%;
  animation: spin 0.8s cubic-bezier(0.5, 0.1, 0.5, 0.9) infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Apple HIG Glass Loading Card & Progress Track */
.kd-loading-card {
  background: rgba(28, 28, 30, 0.85);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
  padding: 32px 28px;
  width: min(450px, 92vw);
  display: flex;
  flex-direction: column;
  align-items: center;
  box-sizing: border-box;
  text-align: center;
}

#analysisNormalState {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.kd-loading-title {
  font-size: 16px;
  font-weight: 700;
  color: #ffffff;
  margin-top: 14px;
  letter-spacing: -0.2px;
}

.kd-loading-sub {
  font-size: 12px;
  color: rgba(235, 235, 245, 0.6);
  margin-top: 4px;
}

.kd-progress-container {
  width: 100%;
  margin-top: 20px;
}

.kd-progress-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.kd-progress-text {
  font-size: 13px;
  color: rgba(235, 235, 245, 0.75);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 320px;
}

.kd-progress-pct {
  font-size: 15px;
  font-weight: 700;
  color: #ffffff;
  font-feature-settings: "tnum";
  font-variant-numeric: tabular-nums;
}

.kd-progress-track {
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  position: relative;
}

.kd-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #30d158, #34c759);
  box-shadow: 0 0 12px rgba(48, 209, 88, 0.5);
  border-radius: 6px;
  transition: width 0.25s ease;
}

/* Error Boundary UI */
.kd-error-box {
  background: rgba(255, 69, 58, 0.08);
  border: 1px solid rgba(255, 69, 58, 0.3);
  border-radius: 14px;
  padding: 18px 20px;
  width: 100%;
  box-sizing: border-box;
  text-align: center;
}

.kd-error-detail {
  font-size: 13px;
  color: rgba(235, 235, 245, 0.85);
  line-height: 1.5;
  margin-bottom: 8px;
  max-height: 120px;
  overflow-y: auto;
  word-break: break-all;
}

.kd-retry-btn {
  background: #0a84ff;
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.kd-retry-btn:hover {
  background: #0071e3;
  transform: translateY(-1px);
}

.kd-close-btn {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  padding: 8px 18px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.kd-close-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

@media (max-width: 1240px) {
  .outer {
    flex-wrap: wrap;
    max-width: 1040px;
  }
  .sidebar-secondary {
    width: 320px;
    flex-direction: row;
    flex-wrap: wrap;
    width: 100%;
    max-width: calc(var(--zoom) * 655px + 340px);
  }
  .sidebar-secondary > * {
    flex: 1 1 260px;
  }
}

@media (max-width: 960px) {
  .outer {
    flex-direction: column;
    align-items: center;
    padding: 0 8px;
    gap: 16px;
  }
  .sidebar, .sidebar-secondary {
    width: 100%;
    max-width: calc(var(--zoom) * 655px);
    height: auto;
  }
  .kd-decision-card {
    min-height: 300px;
  }
  .sidebar-secondary {
    flex-direction: column;
  }
  .controls {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* ============================================================================
   Complete Mobile Viewport Adaptation (360px - 768px Phones & Tablets)
   ============================================================================ */
@media (max-width: 768px) {
  /* Touch devices have no hardware keyboard - hide shortcut cheatsheet */
  .sidebar-secondary, #shortcutsCard {
    display: none !important;
  }

  /* Tier 1 Landing Screen on Mobile */
  .kd-landing-card {
    padding: 24px 16px !important;
    margin: 16px auto !important;
    width: calc(100% - 24px) !important;
    max-width: 440px !important;
    gap: 16px !important;
  }
  .kd-avatar-wrap {
    width: 76px !important;
    height: 76px !important;
  }
  .kd-landing-title {
    font-size: 20px !important;
  }
  .kd-landing-input {
    font-size: 16px !important; /* Prevents iOS Safari auto-zoom on focus */
    padding: 12px 14px !important;
    height: 46px !important;
  }
  .kd-landing-submit {
    height: 46px !important;
    padding: 12px !important;
    font-size: 14px !important;
  }

  /* Header Sticky & Touch Scrolling */
  .kd-header {
    position: sticky !important;
    top: 0 !important;
    z-index: 1000 !important;
    padding: 0 !important;
  }
  .kd-header-row {
    padding: 6px 8px !important;
    gap: 6px !important;
  }
  .kd-header-top {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none !important;
  }
  .kd-header-top::-webkit-scrollbar {
    display: none !important;
  }
  .kd-header-left, .kd-header-right {
    flex-shrink: 0 !important;
    gap: 6px !important;
  }
  .kd-back-btn {
    padding: 5px 8px !important;
    font-size: 12px !important;
  }
  .kd-chip-btn {
    padding: 4px 8px !important;
    font-size: 11px !important;
    white-space: nowrap !important;
  }
  .kd-tab {
    padding: 4px 7px !important;
    font-size: 11px !important;
  }
  .kd-match-badge {
    padding: 4px 8px !important;
    font-size: 11px !important;
    white-space: nowrap !important;
  }

  /* Timeline & Step Scrubber on Mobile */
  .kd-header-bottom {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    padding: 6px 8px !important;
  }
  .kd-step-left {
    flex-shrink: 0 !important;
  }
  .kd-kyoku-select {
    padding: 4px 6px !important;
    font-size: 12px !important;
    max-width: 95px !important;
  }
  .kd-step-mid {
    flex: 1 !important;
    max-width: 100% !important;
    gap: 6px !important;
  }
  .kd-play-btn {
    padding: 4px 10px !important;
    font-size: 11px !important;
    border-radius: 8px !important;
  }
  .kd-speed-select {
    padding: 3px 6px !important;
    font-size: 11px !important;
    border-radius: 7px !important;
  }
  .kd-step-counter {
    font-size: 11px !important;
    min-width: 44px !important;
  }
  .kd-slider {
    flex: 1 !important;
    min-width: 50px !important;
  }

  /* Outer Container & Mahjong Board Grid */
  .outer {
    margin: 6px auto !important;
    padding: 0 4px !important;
    gap: 10px !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }
  .grid-main {
    margin: 0 auto !important;
    max-width: 100vw !important;
  }
  .sidebar {
    width: 100% !important;
    max-width: calc(var(--zoom) * 655px) !important;
    box-sizing: border-box !important;
    gap: 10px !important;
  }
  .controls {
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 5px !important;
    padding: 6px !important;
    border-radius: 12px !important;
  }
  .controls > * {
    padding: 6px 2px !important;
    font-size: 11px !important;
    border-radius: 8px !important;
    min-height: 32px !important;
  }

  /* Center Info Box font size scaling */
  .gi-p0-outer, .gi-p1-outer, .gi-p2-outer, .gi-p3-outer {
    font-size: calc(var(--zoom) * 16px + 2px) !important;
  }
  .info-round {
    font-size: calc(var(--zoom) * 18px + 2px) !important;
  }
  .info-tiles-left {
    font-size: calc(var(--zoom) * 16px + 2px) !important;
  }

  /* Decision Card & Candidate Table on Mobile */
  .kd-decision-card {
    padding: 10px 8px !important;
    border-radius: 14px !important;
    gap: 8px !important;
  }
  .kd-hero-compare-vertical {
    gap: 6px !important;
  }
  .kd-choice-block {
    padding: 6px 10px !important;
    border-radius: 10px !important;
  }
  .kd-choice-badge-label {
    width: 42px !important;
    font-size: 13px !important;
  }
  .kd-choice-tile-wrap {
    width: 36px !important;
    height: 48px !important;
  }
  .kd-choice-tile-wrap.has-rotate,
  .kd-choice-tile-wrap:has(img.rotate) {
    width: 48px !important;
    height: 36px !important;
  }

  /* Candidate Table Columns on Mobile */
  .kd-cand-table {
    width: 100% !important;
    table-layout: fixed !important;
  }
  .kd-cand-table col:nth-child(1) { width: 44px !important; }
  .kd-cand-table col:nth-child(2) { width: 46px !important; }
  .kd-cand-table col:nth-child(3) { width: 68px !important; }
  .kd-cand-table col:nth-child(4) { width: 56px !important; }
  .kd-cand-table col:nth-child(5) { width: auto !important; }

  .kd-cand-table th, .kd-cand-table td {
    padding: 5px 2px !important;
    font-size: 11px !important;
  }
  .kd-cand-tile-img {
    width: 20px !important;
    height: 27px !important;
  }
  .kd-cand-action {
    font-size: 11px !important;
    padding: 2px 4px !important;
  }
  .kd-tag-shanten {
    font-size: 10px !important;
    padding: 1px 3px !important;
  }

  /* Settlement Card on Mobile */
  .kd-settlement-banner {
    padding: 10px !important;
  }
  .kd-settlement-agari-tile-wrap {
    width: 36px !important;
    height: 48px !important;
  }
  .kd-settlement-winner-title {
    font-size: 13px !important;
  }
  .kd-settlement-score-tag {
    font-size: 17px !important;
  }
  .kd-settlement-delta-cell {
    padding: 5px 2px !important;
    font-size: 10.5px !important;
  }
  .kd-settlement-delta-pts {
    font-size: 11.5px !important;
  }
  .kd-settlement-uradora-tile {
    width: 18px !important;
    height: 24px !important;
  }

  /* Modals on Mobile */
  .modal {
    max-width: calc(100% - 20px) !important;
    width: 100% !important;
    padding: 16px !important;
    border-radius: 16px !important;
    max-height: 88vh !important;
  }
  .info-round-table {
    max-height: calc(80vh - 120px) !important;
  }
}

@media (max-width: 380px) {
  .kd-model-group {
    flex-wrap: wrap !important;
  }
  .kd-model-btn {
    flex: 1 1 45% !important;
  }
  .kd-cand-table col:nth-child(1) { width: 38px !important; }
  .kd-cand-table col:nth-child(2) { width: 42px !important; }
  .kd-cand-table col:nth-child(3) { width: 62px !important; }
  .kd-cand-table col:nth-child(4) { width: 50px !important; }
  .kd-cand-table col:nth-child(5) { width: auto !important; }
}


/* Settlement Hora Kyotaku, Han/Fu & Yaku Chips */
.kd-settlement-kyotaku-strip.hora {
  background: rgba(48, 209, 88, 0.08);
  border-color: rgba(48, 209, 88, 0.28);
}
.kd-settlement-kyotaku-strip.hora .kd-kyotaku-pill {
  background: rgba(48, 209, 88, 0.16);
  border-color: rgba(48, 209, 88, 0.35);
}
.kd-settlement-kyotaku-strip.hora .kd-kyotaku-tag {
  color: #30d158;
}

.kd-settlement-score-tag {
  display: flex !important;
  flex-direction: column !important;
  align-items: flex-end !important;
  justify-content: center !important;
  gap: 2px !important;
}
.kd-settlement-score-sub {
  font-size: 11px;
  font-weight: 600;
  color: rgba(235, 235, 245, 0.65);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  letter-spacing: normal;
  text-shadow: none;
}

.kd-settlement-hanfu-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
  flex-wrap: wrap;
}
.kd-settlement-hanfu-pill {
  font-size: 11.5px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  letter-spacing: 0.3px;
}
.kd-settlement-title-pill {
  font-size: 11px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 5px;
  background: rgba(255, 214, 10, 0.16);
  color: #ffd60a;
  border: 1px solid rgba(255, 214, 10, 0.35);
  letter-spacing: 0.5px;
}
.kd-settlement-title-pill.mangan {
  background: rgba(255, 159, 10, 0.18);
  color: #ff9f0a;
  border-color: rgba(255, 159, 10, 0.4);
}
.kd-settlement-title-pill.haneman,
.kd-settlement-title-pill.baiman {
  background: rgba(255, 69, 58, 0.18);
  color: #ff453a;
  border-color: rgba(255, 69, 58, 0.4);
}
.kd-settlement-title-pill.yakuman {
  background: linear-gradient(135deg, rgba(255, 214, 10, 0.3), rgba(255, 69, 58, 0.3));
  color: #ffd60a;
  border-color: rgba(255, 214, 10, 0.6);
  box-shadow: 0 0 10px rgba(255, 214, 10, 0.3);
}

.kd-settlement-yaku-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.kd-settlement-yaku-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 5px;
  padding: 2px 7px;
  font-size: 11px;
}
.kd-settlement-yaku-chip .kd-yaku-name {
  color: rgba(235, 235, 245, 0.9);
  font-weight: 600;
}
.kd-settlement-yaku-chip .kd-yaku-val {
  color: #30d158;
  font-weight: 700;
  font-family: ui-monospace, monospace;
}
.kd-settlement-yaku-chip.dora {
  border-color: rgba(255, 69, 58, 0.3);
  background: rgba(255, 69, 58, 0.08);
}
.kd-settlement-yaku-chip.dora .kd-yaku-val {
  color: #ff453a;
}





/* ==========================================================================
   Score Fluctuations SVG Chart & Import/Export Buttons (Module 3)
   ========================================================================== */
.kd-landing-actions {
  display: flex;
  gap: 10px;
  width: 100%;
}
.kd-landing-actions .kd-landing-submit {
  flex: 1;
}
.kd-landing-import-btn {
  padding: 13px 18px;
  font-size: 14px;
  font-weight: 600;
  background: var(--color-bg-card, #2c2c2e);
  color: var(--color-text-primary, #ffffff);
  border: 1px solid var(--color-border, rgba(255, 255, 255, 0.12));
  border-radius: 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s cubic-bezier(0.25, 1, 0.5, 1);
  display: flex;
  align-items: center;
  gap: 6px;
}
.kd-landing-import-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.24);
  transform: translateY(-1px);
}
.kd-landing-import-btn:active {
  transform: translateY(0);
}

.round-score-chart-wrap {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--color-border, rgba(255, 255, 255, 0.08));
  border-radius: 8px;
  padding: 12px 14px;
}
.round-score-chart-legend {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.score-chart-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--color-text-secondary, rgba(235, 235, 245, 0.6));
  cursor: default;
}
.score-chart-legend-item.is-target {
  font-weight: 700;
  color: #ffffff;
}
.score-chart-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.score-chart-legend-tag {
  font-size: 10px;
  padding: 1px 4px;
  border-radius: 3px;
  background: rgba(255, 214, 10, 0.2);
  color: #ffd60a;
}
.round-score-chart-svg-container {
  width: 100%;
  overflow-x: auto;
}
.score-fluctuations-svg {
  width: 100%;
  height: auto;
  display: block;
}


/* Honba mini stick icon */
.honba-stick-mini {
  width: 10px;
  height: 3px;
  background: #ffffff;
  border-radius: 1px;
  display: inline-block;
  position: relative;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}
.honba-stick-mini::after {
  content: "";
  width: 2px;
  height: 2px;
  background: #1c1c1e;
  border-radius: 50%;
  position: absolute;
  left: 4px;
  top: 0.5px;
}

/* Base dadian pill */
.kd-settlement-dadian-pill {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(235, 235, 245, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.15);
  letter-spacing: 0.3px;
}

.kd-settlement-tsumo-honba-note {
  font-size: 11px;
  color: rgba(235, 235, 245, 0.65);
  font-weight: normal;
  margin-left: 4px;
}

/* Unified Bonus Strips (Honba & Kyotaku) */
.kd-settlement-bonus-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: 8px;
  padding: 6px 12px;
  margin-top: 6px;
  box-sizing: border-box;
  width: 100%;
}
.kd-settlement-bonus-strip.honba {
  background: rgba(255, 214, 10, 0.08);
  border: 1px solid rgba(255, 214, 10, 0.28);
}
.kd-settlement-bonus-strip.honba .kd-bonus-pill {
  background: rgba(255, 214, 10, 0.16);
  border: 1px solid rgba(255, 214, 10, 0.35);
}
.kd-settlement-bonus-strip.honba .kd-bonus-tag {
  color: #ffd60a;
}

.kd-settlement-bonus-strip.kyotaku {
  background: rgba(48, 209, 88, 0.08);
  border: 1px solid rgba(48, 209, 88, 0.28);
}
.kd-settlement-bonus-strip.kyotaku .kd-bonus-pill {
  background: rgba(48, 209, 88, 0.16);
  border: 1px solid rgba(48, 209, 88, 0.35);
}
.kd-settlement-bonus-strip.kyotaku .kd-bonus-tag {
  color: #30d158;
}

.kd-bonus-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: 5px;
  white-space: nowrap;
}
.kd-bonus-tag {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.kd-bonus-pts {
  font-size: 13.5px;
  font-weight: 800;
  color: #ffffff;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.5px;
}
.kd-bonus-desc {
  font-size: 11px;
  color: rgba(235, 235, 245, 0.6);
  white-space: nowrap;
}
