:root {
  --primary-dark: #1a1a2e;
  --primary-light: #f8f7f5;
  --accent-warm: #e6a756;
  --accent-cool: #4a9d8e;
  --accent-red: #c94c4c;
  --accent-blue: #4a6fa5;
  --border-color: #e0ddd8;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.12);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.18);
  --font-display: 'Noto Serif KR', serif;
  --font-body: 'Noto Sans KR', sans-serif;
  --gradient-gold: linear-gradient(135deg, #e6a756 0%, #d4943c 100%);
  --gradient-dark: linear-gradient(135deg, #1a1a2e 0%, #2d2d44 100%);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body,
#root {
  width: 100%;
  min-height: 100vh;
}

body {
  font-family: var(--font-body);
  background: linear-gradient(180deg, #1a1a2e 0%, #0f0f1a 100%);
  color: var(--primary-light);
  line-height: 1.6;
  overflow-x: hidden;
  max-width: 100vw;
  transition: background 0.3s, color 0.3s;
}

/* ===== LIGHT MODE ===== */
body.light-mode {
  background: linear-gradient(180deg, #f5f5f5 0%, #e8e8e8 100%);
  color: #1a1a2e;
}

body.light-mode .app-header {
  background: linear-gradient(135deg, #f0f0f0 0%, #e5e5e5 100%);
}

body.light-mode .rule-context-bar .context-control {
  color: #1a1a2e;
}

body.light-mode .rule-context-bar select {
  background: rgba(0, 0, 0, 0.08);
  color: #1a1a2e;
  border-color: rgba(0, 0, 0, 0.2);
}

body.light-mode .app-header h1 {
  background: linear-gradient(135deg, #c4873a 0%, #a06a20 100%);
  -webkit-background-clip: text;
  background-clip: text;
}

body.light-mode .main-nav {
  background: rgba(0, 0, 0, 0.03);
  border-bottom-color: rgba(0, 0, 0, 0.1);
}

body.light-mode .nav-btn {
  background: rgba(0, 0, 0, 0.05);
  color: rgba(0, 0, 0, 0.7);
}

body.light-mode .nav-btn.active {
  background: var(--gradient-gold);
  color: white;
}

body.light-mode .card {
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(0, 0, 0, 0.1);
}

body.light-mode .card-header h2 {
  color: #1a1a2e;
}

body.light-mode .lesson-content p,
body.light-mode .practice-mission p,
body.light-mode .dropdown-content {
  color: rgba(0, 0, 0, 0.7);
}

body.light-mode .lesson-detail-text {
  color: rgba(0, 0, 0, 0.8);
}

body.light-mode .lesson-subtitle {
  color: #a06a20 !important;
}

body.light-mode .btn-secondary {
  background: rgba(0, 0, 0, 0.1);
  color: rgba(0, 0, 0, 0.8);
}

body.light-mode .btn-secondary:hover {
  background: rgba(0, 0, 0, 0.15);
}

body.light-mode .btn-quiz-close {
  background: rgba(0, 0, 0, 0.1);
  color: #1a1a2e;
}

body.light-mode .btn-quiz-close:hover {
  background: rgba(0, 0, 0, 0.2);
}

body.light-mode .dropdown-header {
  background: rgba(0, 0, 0, 0.05);
}

body.light-mode .dropdown-header:hover {
  background: rgba(0, 0, 0, 0.1);
}

body.light-mode .dropdown-header h3 {
  color: #c4873a;
}

body.light-mode .practice-mission {
  background: linear-gradient(135deg, rgba(74, 157, 142, 0.15), rgba(74, 157, 142, 0.05));
}

body.light-mode .hand-area {
  background: rgba(0, 0, 0, 0.05);
}

body.light-mode .result-card {
  background: linear-gradient(135deg, rgba(230, 167, 86, 0.1), rgba(230, 167, 86, 0.05));
}

body.light-mode .sidebar-card {
  background: rgba(255, 255, 255, 0.8);
  border-color: rgba(0, 0, 0, 0.1);
}

body.light-mode .yaku-card {
  background: rgba(0, 0, 0, 0.03);
}

.mahjong-app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ===== THEME & YAKU TOGGLE ===== */
.header-btn {
  position: absolute;
  top: 20px;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: white;
  font-size: 20px;
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.theme-toggle {
  right: 20px;
}

.yaku-sheet-toggle {
  left: 20px;
}

.header-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.1);
}

body.light-mode .header-btn {
  background: rgba(0, 0, 0, 0.1);
  color: #1a1a2e;
}

body.light-mode .header-btn:hover {
  background: rgba(0, 0, 0, 0.2);
}

/* ===== YAKU SHEET MODAL ===== */
.yaku-modal-content {
  max-width: 900px;
  width: 95%;
  max-height: 90vh;
  overflow-y: auto;
}

.yaku-table-section {
  margin-bottom: 30px;
}

.yaku-table-section h3 {
  color: var(--accent-warm);
  margin-bottom: 15px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--accent-warm);
  display: flex;
  align-items: center;
  gap: 10px;
}

.yaku-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  overflow: hidden;
}

body.light-mode .yaku-table {
  background: rgba(0, 0, 0, 0.03);
}

.yaku-table th,
.yaku-table td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

body.light-mode .yaku-table th,
body.light-mode .yaku-table td {
  border-bottom-color: rgba(0, 0, 0, 0.1);
}

.yaku-table th {
  background: rgba(255, 255, 255, 0.05);
  color: var(--accent-warm);
  font-weight: 700;
}

body.light-mode .yaku-table th {
  background: rgba(0, 0, 0, 0.05);
}

.yaku-row-name {
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
}

body.light-mode .yaku-row-name {
  color: #1a1a2e;
}

.yaku-row-example {
  display: flex;
  gap: 2px;
  margin-top: 5px;
}

.legend-box {
  background: rgba(201, 76, 76, 0.1);
  padding: 15px;
  border-radius: 8px;
  margin-bottom: 20px;
  border-left: 4px solid var(--accent-red);
}

.legend-box ul {
  list-style: none;
  font-size: 13px;
}

.legend-box li {
  margin-bottom: 5px;
}

.yaku-badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  margin-right: 5px;
}

.badge-menzen {
  background: #4a6fa5;
  color: white;
}

.badge-naki {
  background: #4a9d8e;
  color: white;
}

.badge-down {
  background: #c94c4c;
  color: white;
}

.badge-special {
  background: #9b59b6;
  color: white;
}

/* ===== HEADER ===== */
.app-header {
  position: relative;
  background: var(--gradient-dark);
  padding: 20px 24px;
  border-bottom: 3px solid var(--accent-warm);
  text-align: center;
}

.app-header h1 {
  font-family: var(--font-display);
  font-size: 28px;
  background: var(--gradient-gold);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.app-header p {
  font-size: 13px;
  opacity: 0.7;
  margin-top: 4px;
}

.rule-context-bar {
  margin-top: 12px;
  display: flex;
  gap: 10px;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
}

.rule-context-bar .context-control {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.85);
}

.rule-context-bar select {
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 12px;
}

.rule-note {
  margin-top: 8px;
  font-size: 12px;
  opacity: 0.75;
}

/* ===== NAVIGATION ===== */
.main-nav {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.03);
  overflow-x: auto;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.nav-btn {
  flex-shrink: 0;
  padding: 10px 18px;
  border: none;
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.7);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.nav-btn.active {
  background: var(--gradient-gold);
  color: #1a1a2e;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(230, 167, 86, 0.3);
}

.nav-btn .icon {
  font-size: 16px;
}

/* ===== MAIN CONTAINER ===== */
.app-container {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  padding: 20px;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

@media (min-width: 1024px) {
  .app-container {
    grid-template-columns: 1fr 380px;
  }
}

/* ===== CARDS ===== */
.card {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 16px;
  padding: 24px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(10px);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.card-header h2 {
  font-family: var(--font-display);
  font-size: 20px;
  color: var(--accent-warm);
}

.card-header .badge {
  background: var(--accent-cool);
  color: white;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
}

/* ===== LESSON CONTENT ===== */
.lesson-content {
  line-height: 1.8;
}

.lesson-content h3 {
  color: var(--accent-warm);
  font-size: 16px;
  margin: 20px 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.lesson-content h3::before {
  content: '';
  width: 4px;
  height: 16px;
  background: var(--accent-warm);
  border-radius: 2px;
}

.lesson-content p {
  color: rgba(255, 255, 255, 0.8);
  margin-bottom: 12px;
  font-size: 14px;
}

.lesson-detail-text {
  color: rgba(255, 255, 255, 0.8);
  font-size: 13px;
  line-height: 1.8;
  margin: 4px 0;
}

.lesson-subtitle {
  color: var(--accent-warm);
  margin-top: 4px;
  font-size: 14px;
}

/* ===== TILE EXAMPLES ===== */
.tile-example {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 12px;
  margin: 16px 0;
  flex-wrap: wrap;
}

.tile-example .label {
  font-size: 13px;
  color: var(--accent-warm);
  font-weight: 600;
  min-width: 80px;
}

.tile-example .tiles {
  display: flex;
  gap: 4px;
}

.example-tile {
  width: 54px;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  /* Image provides background */
  border: none;
  /* box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3); */
  overflow: hidden;
}

/* ===== YAKU CARDS ===== */
.yaku-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.yaku-card {
  background: rgba(0, 0, 0, 0.3);
  border-radius: 12px;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: all 0.3s;
}

.yaku-card:hover {
  transform: translateY(-4px);
  border-color: var(--accent-warm);
  box-shadow: 0 8px 24px rgba(230, 167, 86, 0.15);
}

.yaku-card .yaku-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.yaku-card .yaku-name {
  font-family: var(--font-display);
  font-size: 18px;
  color: #fff;
}

.yaku-card .yaku-han {
  background: var(--accent-red);
  color: white;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
}

.yaku-card .yaku-desc {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.7);
  margin-bottom: 12px;
}

.yaku-card .yaku-example {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
}

.yaku-card .mini-tile {
  width: 32px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
}

/* ===== PRACTICE MODE ===== */
.practice-mission {
  background: linear-gradient(135deg, rgba(74, 157, 142, 0.2), rgba(74, 157, 142, 0.05));
  border: 1px solid var(--accent-cool);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 20px;
}

.practice-mission h4 {
  color: var(--accent-cool);
  font-size: 14px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.practice-mission p {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.8);
}

/* ===== DROPDOWN/ACCORDION ===== */
.dropdown-section {
  margin-bottom: 12px;
}

.dropdown-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
}

.dropdown-header:hover {
  background: rgba(255, 255, 255, 0.1);
}

.dropdown-header h3 {
  font-size: 14px;
  color: var(--accent-warm);
  margin: 0;
}

.dropdown-header .arrow {
  font-size: 12px;
  transition: transform 0.2s;
}

.dropdown-header.open .arrow {
  transform: rotate(180deg);
}

.dropdown-content {
  padding: 12px 16px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.7);
}

.dropdown-content.hidden {
  display: none;
}

/* ===== TILES SELECTOR ===== */
.tiles-section h3 {
  font-size: 14px;
  color: var(--accent-warm);
  margin-bottom: 12px;
}

.tiles-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.tiles-grid.honors {
  display: flex;
  flex-wrap: wrap;
}

.tile-btn {
  position: relative;
  width: 54px;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.15s;
  /* box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); */
  overflow: visible;
  /* changed to visible for count badge? or keep hidden? */
}

.tile-btn>span:first-child,
.tile-btn::before {
  font-size: 68px;
}

.tile-btn .tile-char {
  transform: scale(1.15);
}

.tile-btn:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
}

.tile-btn:active {
  transform: translateY(2px);
  border-bottom-width: 3px;
}

.tile-btn.selected {
  box-shadow: 0 0 0 3px var(--accent-warm), 0 8px 16px rgba(0, 0, 0, 0.3);
}

.tile-btn .count {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 24px;
  height: 24px;
  background: var(--accent-red);
  color: white;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid white;
}

/* ===== HAND DISPLAY ===== */
.hand-area {
  background: rgba(0, 0, 0, 0.4);
  border-radius: 12px;
  padding: 16px;
  margin-top: 20px;
}

.hand-area h4 {
  font-size: 13px;
  color: var(--accent-warm);
  margin-bottom: 12px;
}

.hand-tiles {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  min-height: 60px;
}

.hand-tile {
  width: 44px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  cursor: pointer;
}

.hand-tile:hover {
  opacity: 0.7;
}

.hand-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.agari-picker {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed rgba(255, 255, 255, 0.2);
}

.agari-picker-title {
  font-size: 12px;
  color: var(--accent-warm);
  margin-bottom: 8px;
}

.agari-tiles {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.agari-tile-btn {
  width: 40px;
  height: 56px;
  border: 2px solid transparent;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  padding: 0;
}

.agari-tile-btn.selected {
  border-color: var(--accent-cool);
  box-shadow: 0 0 0 2px rgba(74, 157, 142, 0.35);
}

.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--gradient-gold);
  color: #1a1a2e;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

.btn-quiz-close {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  color: white;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
}

.btn-quiz-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

.btn:hover {
  transform: translateY(-2px);
}

/* ===== QUIZ MODAL ===== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-content {
  background: linear-gradient(135deg, #2d2d44 0%, #1a1a2e 100%);
  border-radius: 16px;
  padding: 24px;
  max-width: 400px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  border: 2px solid var(--accent-warm);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

body.light-mode .modal-content {
  background: linear-gradient(135deg, #ffffff 0%, #f5f5f5 100%);
  color: #1a1a2e;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.modal-header h2 {
  font-size: 20px;
  color: var(--accent-warm);
}

.modal-close {
  width: 36px;
  height: 36px;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
}

body.light-mode .modal-close {
  background: rgba(0, 0, 0, 0.1);
  color: #1a1a2e;
}

.quiz-question {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 16px;
  text-align: center;
}

.quiz-progress {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-bottom: 16px;
}

.quiz-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
}

.quiz-dot.active {
  background: var(--accent-warm);
}

.quiz-dot.correct {
  background: var(--accent-cool);
}

.quiz-dot.wrong {
  background: var(--accent-red);
}

.quiz-tiles {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 20px;
}

.quiz-tile {
  width: 48px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  background: linear-gradient(135deg, #fff 0%, #f5f2e9 100%);
  border-radius: 6px;
  border-bottom: 4px solid #e6b422;
  border-right: 2px solid #c99a15;
  cursor: pointer;
  transition: all 0.2s;
}

.quiz-tile:hover {
  transform: scale(1.1);
}

.quiz-tile.selected {
  box-shadow: 0 0 0 3px var(--accent-cool);
}

.quiz-tile.correct {
  box-shadow: 0 0 0 3px #4a9d8e;
  background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
}

.quiz-tile.wrong {
  box-shadow: 0 0 0 3px #c94c4c;
  opacity: 0.5;
}

/* ===== RED DORA (적도라) ===== */
.tile-red {
  box-shadow: 0 0 0 3px #ff4444, inset 0 0 10px rgba(255, 68, 68, 0.3);
  background: linear-gradient(135deg, #fff5f5 0%, #ffe0e0 100%);
}

.example-tile.tile-red,
.quiz-tile.tile-red {
  box-shadow: 0 0 0 3px #ff4444, inset 0 0 10px rgba(255, 68, 68, 0.3);
  background: linear-gradient(135deg, #fff5f5 0%, #ffe0e0 100%);
}

/* ===== TEXT QUIZ OPTIONS ===== */
.quiz-text-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.quiz-text-option {
  padding: 14px 20px;
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  color: inherit;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
}

.quiz-text-option:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: var(--accent-warm);
}

.quiz-text-option.selected {
  background: rgba(74, 157, 142, 0.4);
  border-color: #4a9d8e;
  box-shadow: 0 0 0 3px rgba(74, 157, 142, 0.3);
}

.quiz-text-option.correct {
  background: rgba(74, 157, 142, 0.3);
  border-color: #4a9d8e;
}

.quiz-text-option.wrong {
  background: rgba(201, 76, 76, 0.2);
  border-color: #c94c4c;
}

body.light-mode .quiz-text-option {
  background: rgba(0, 0, 0, 0.05);
  border-color: rgba(0, 0, 0, 0.15);
}

body.light-mode .quiz-text-option:hover {
  background: rgba(0, 0, 0, 0.1);
}

.quiz-feedback {
  text-align: center;
  font-size: 24px;
  margin-bottom: 16px;
}

.quiz-result {
  text-align: center;
  padding: 20px;
}

.quiz-result h3 {
  font-size: 24px;
  color: var(--accent-warm);
  margin-bottom: 12px;
}

.quiz-score {
  font-size: 48px;
  font-weight: 700;
  color: var(--accent-cool);
}

.quiz-tiles {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin: 20px 0;
}

.quiz-tile {
  width: 54px;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  /* Image provides background */
  border: 3px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.quiz-tile:hover {
  transform: translateY(-4px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.quiz-tile.selected {
  border-color: var(--accent-warm);
  transform: translateY(-4px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.quiz-tile.correct {
  border-color: var(--accent-cool);
  background: rgba(74, 157, 142, 0.2);
}

.quiz-tile.wrong {
  border-color: var(--accent-red);
  opacity: 0.5;
}

.mission-btn {
  width: 100%;
  padding: 12px;
  background: var(--gradient-gold);
  border: none;
  border-radius: 8px;
  color: #1a1a2e;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 12px;
}

.mission-btn:hover {
  transform: scale(1.02);
}

.solo-launch-btn {
  background: linear-gradient(135deg, #4a9d8e 0%, #2f7a6e 100%);
  color: #f8f7f5;
}

.solo-modal-content {
  max-width: 760px;
  width: 95%;
}

.solo-help {
  font-size: 14px;
  opacity: 0.9;
  margin-bottom: 12px;
}

.solo-mission-box {
  margin-bottom: 12px;
  background: rgba(230, 167, 86, 0.14);
  border: 1px solid rgba(230, 167, 86, 0.45);
  border-radius: 10px;
  padding: 10px;
}

body.light-mode .solo-mission-box {
  background: rgba(230, 167, 86, 0.1);
}

.solo-mission-box.is-success {
  border-color: rgba(74, 157, 142, 0.7);
  background: rgba(74, 157, 142, 0.16);
}

.solo-mission-box.is-failed {
  border-color: rgba(201, 76, 76, 0.7);
  background: rgba(201, 76, 76, 0.16);
}

.solo-mission-box h4 {
  margin-bottom: 4px;
}

.solo-mission-title {
  font-size: 14px;
  font-weight: 700;
}

.solo-mission-desc,
.solo-mission-progress,
.solo-mission-status {
  font-size: 12px;
  line-height: 1.45;
}

.solo-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.solo-stats span {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 13px;
}

body.light-mode .solo-stats span {
  background: rgba(0, 0, 0, 0.08);
}

.solo-result.is-win {
  color: #74d7c7;
}

.solo-result.is-lose {
  color: #ff9f9f;
}

.solo-message {
  font-size: 14px;
  margin-bottom: 14px;
}

.solo-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.solo-actions .btn {
  flex: 1;
  min-width: 120px;
}

.coach-toggle-btn {
  border: 1px solid rgba(230, 167, 86, 0.6);
}

.coach-mode-box {
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.coach-mode-label {
  font-size: 13px;
  opacity: 0.9;
}

.coach-mode-actions {
  display: flex;
  gap: 8px;
}

.coach-mode-btn {
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.08);
  color: inherit;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

body.light-mode .coach-mode-btn {
  border-color: rgba(0, 0, 0, 0.2);
  background: rgba(0, 0, 0, 0.05);
}

.coach-mode-btn.active {
  background: var(--gradient-gold);
  color: #1a1a2e;
  border-color: transparent;
}

.mission-difficulty-box .coach-mode-btn:last-child.active {
  background: linear-gradient(135deg, #c94c4c 0%, #9f3434 100%);
  color: #fff;
}

.solo-coach-box {
  background: rgba(74, 111, 165, 0.2);
  border: 1px solid rgba(74, 111, 165, 0.45);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 14px;
}

body.light-mode .solo-coach-box {
  background: rgba(74, 111, 165, 0.1);
}

.solo-coach-box h4 {
  margin-bottom: 8px;
}

.solo-coach-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.solo-coach-item {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  gap: 8px;
  align-items: center;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 8px;
  font-size: 13px;
}

body.light-mode .solo-coach-item {
  background: rgba(255, 255, 255, 0.7);
}

.solo-coach-rank {
  color: var(--accent-warm);
  font-weight: 700;
}

.solo-coach-main {
  font-weight: 600;
}

.solo-coach-meta {
  opacity: 0.9;
}

.solo-hand-wrap {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 14px;
}

body.light-mode .solo-hand-wrap {
  background: rgba(0, 0, 0, 0.06);
}

.solo-hand-wrap h4 {
  margin-bottom: 10px;
}

.solo-hand-tiles {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.solo-hand-tile {
  position: relative;
  width: 40px;
  height: 56px;
  border: 2px solid transparent;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.95);
  padding: 0;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.solo-hand-tile.can-discard:hover {
  transform: translateY(-3px);
  border-color: var(--accent-red);
}

.solo-hand-tile.is-good {
  border-color: rgba(74, 157, 142, 0.9);
}

.solo-hand-tile.is-mid {
  border-color: rgba(230, 167, 86, 0.9);
}

.solo-hand-tile.is-bad {
  border-color: rgba(201, 76, 76, 0.9);
}

.solo-advice-chip {
  position: absolute;
  top: -8px;
  right: -4px;
  padding: 2px 5px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  background: rgba(26, 26, 46, 0.85);
}

.solo-hand-tile.is-good .solo-advice-chip {
  background: #2f7a6e;
}

.solo-hand-tile.is-mid .solo-advice-chip {
  background: #b8792a;
}

.solo-hand-tile.is-bad .solo-advice-chip {
  background: #9f3434;
}

.solo-hand-tile:disabled {
  opacity: 0.7;
  cursor: default;
}

.solo-yaku-box {
  background: rgba(230, 167, 86, 0.12);
  border-radius: 10px;
  padding: 12px;
}

body.light-mode .solo-yaku-box {
  background: rgba(230, 167, 86, 0.14);
}

.solo-yaku-box h4 {
  margin-bottom: 8px;
}

.solo-review-box {
  margin-top: 14px;
  background: rgba(201, 76, 76, 0.14);
  border: 1px solid rgba(201, 76, 76, 0.5);
  border-radius: 12px;
  padding: 12px;
}

body.light-mode .solo-review-box {
  background: rgba(201, 76, 76, 0.08);
}

.solo-review-box h4 {
  margin-bottom: 8px;
}

.solo-review-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.solo-review-item {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 8px;
}

body.light-mode .solo-review-item {
  background: rgba(255, 255, 255, 0.75);
}

.solo-review-title {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 4px;
}

.solo-review-desc {
  font-size: 12px;
  opacity: 0.92;
}

.solo-review-gap {
  margin-top: 3px;
  font-size: 12px;
  color: #ffb1b1;
  font-weight: 700;
}

.solo-history-box {
  margin-top: 14px;
  background: rgba(74, 157, 142, 0.13);
  border: 1px solid rgba(74, 157, 142, 0.45);
  border-radius: 12px;
  padding: 12px;
}

body.light-mode .solo-history-box {
  background: rgba(74, 157, 142, 0.08);
}

.solo-history-box h4 {
  margin-bottom: 8px;
}

.solo-summary-box {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.solo-summary-item {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

body.light-mode .solo-summary-item {
  background: rgba(255, 255, 255, 0.75);
}

.solo-summary-item span {
  font-size: 11px;
  opacity: 0.88;
}

.solo-summary-item strong {
  font-size: 14px;
}

.solo-tip-box {
  margin-bottom: 10px;
  background: rgba(230, 167, 86, 0.14);
  border: 1px solid rgba(230, 167, 86, 0.45);
  border-radius: 10px;
  padding: 10px;
}

body.light-mode .solo-tip-box {
  background: rgba(230, 167, 86, 0.1);
}

.solo-tip-box h5 {
  font-size: 13px;
  margin-bottom: 6px;
}

.solo-tip-list {
  margin-left: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.solo-tip-list li {
  font-size: 12px;
  line-height: 1.45;
}

.solo-history-filters {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.solo-history-filter-label {
  font-size: 12px;
  opacity: 0.9;
}

.solo-history-filter-actions {
  display: flex;
  gap: 6px;
}

.solo-history-filter-btn {
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.08);
  color: inherit;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

body.light-mode .solo-history-filter-btn {
  border-color: rgba(0, 0, 0, 0.2);
  background: rgba(0, 0, 0, 0.05);
}

.solo-history-filter-btn.active {
  background: var(--gradient-gold);
  color: #1a1a2e;
  border-color: transparent;
}

.solo-history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 240px;
  overflow-y: auto;
  padding-right: 4px;
}

.solo-history-item {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 8px;
}

body.light-mode .solo-history-item {
  background: rgba(255, 255, 255, 0.75);
}

.solo-history-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 12px;
}

.solo-history-turn {
  font-weight: 700;
}

.solo-history-level {
  border-radius: 999px;
  padding: 2px 6px;
  color: #fff;
  font-weight: 700;
}

.solo-history-level.is-good {
  background: #2f7a6e;
}

.solo-history-level.is-mid {
  background: #b8792a;
}

.solo-history-level.is-bad {
  background: #9f3434;
}

.solo-history-gap {
  margin-left: auto;
  opacity: 0.92;
}

.solo-history-line {
  font-size: 12px;
  opacity: 0.92;
}

.solo-history-line.alt {
  color: var(--accent-warm);
}

/* ===== SIDEBAR ===== */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.result-card {
  background: linear-gradient(135deg, rgba(230, 167, 86, 0.15), rgba(230, 167, 86, 0.05));
  border: 1px solid var(--accent-warm);
}

.result-card .yaku-list {
  margin-top: 12px;
}

.result-card .yaku-item {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 14px;
}

.result-card .yaku-item:last-child {
  border: none;
}

.result-card .total {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 2px solid var(--accent-warm);
  display: flex;
  justify-content: space-between;
  font-size: 18px;
  font-weight: 700;
  color: var(--accent-warm);
}

.info-card p {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.7);
}

/* ===== FOOTER ===== */
.app-footer {
  background: rgba(0, 0, 0, 0.3);
  text-align: center;
  padding: 16px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.footer-inline {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.footer-link-btn {
  border: none;
  background: transparent;
  color: var(--accent-warm);
  font-size: 12px;
  text-decoration: underline;
  cursor: pointer;
}

.privacy-modal-content {
  max-width: 760px;
  width: 95%;
  max-height: 86vh;
}

.privacy-content h3 {
  margin-top: 12px;
  margin-bottom: 6px;
  color: var(--accent-warm);
  font-size: 16px;
}

.privacy-content p {
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 8px;
}

.privacy-content a {
  color: var(--accent-cool);
}

/* ===== MOBILE OPTIMIZATIONS ===== */
@media (max-width: 1023px) {
  .app-container {
    padding: 12px;
    gap: 24px;
    display: flex;
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    order: 2;
    /* 아래로 배치 */
  }
}

@media (max-width: 768px) {
  body {
    font-size: 14px;
  }

  .app-header {
    padding: 12px 16px;
  }

  .app-header h1 {
    font-size: 20px;
  }

  .main-nav {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding: 8px 12px;
    justify-content: flex-start;
    gap: 8px;
    background: rgba(0, 0, 0, 0.2);
    -webkit-overflow-scrolling: touch;
  }

  .main-nav::-webkit-scrollbar {
    height: 0px;
    /* 스크롤바 숨김 */
    background: transparent;
  }

  .nav-btn {
    flex: 0 0 auto;
    padding: 10px 14px;
    font-size: 14px;
    height: 44px;
    /* 최소 터치 영역 */
  }

  .card {
    padding: 16px;
    margin-bottom: 12px;
    border-radius: 12px;
  }

  /* 터치 친화적 타일 버튼 */
  .tiles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
    gap: 6px;
    justify-content: center;
  }

  .tile-btn {
    width: 100%;
    height: 64px;
    font-size: 48px;
    margin: 0 auto;
  }

  .hand-tiles {
    flex-wrap: wrap;
    justify-content: center;
  }

  /* 사이드바 미션/퀴즈 강조 */
  .mission-btn {
    padding: 16px;
    /* 터치 영역 확대 */
    font-size: 16px;
  }

  /* 퀴즈 모달 최적화 */
  .quiz-modal-content {
    width: 95%;
    padding: 20px;
    max-height: 90vh;
    overflow-y: auto;
  }

  .quiz-tile {
    width: 40px;
    height: 52px;
    font-size: 32px;
  }
}

/* 역 판정 시각화 */
.yaku-item-container {
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding: 8px 0;
}

.yaku-item {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  font-weight: 500;
}

.yaku-visual {
  display: flex;
  gap: 2px;
  margin-top: 6px;
  flex-wrap: wrap;
  padding-bottom: 4px;
}

.yaku-visual .mini-tile {
  width: 20px;
  height: 28px;
  font-size: 18px;
  border-radius: 2px;
  border: 1px solid rgba(0, 0, 0, 0.1);
}

.yaku-reason {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.7);
  margin: 4px 0 2px;
}

body.light-mode .yaku-reason {
  color: rgba(0, 0, 0, 0.7);
}

@media (max-width: 768px) {
  .rule-context-bar {
    gap: 8px;
  }

  .rule-context-bar .context-control {
    font-size: 11px;
  }

  .rule-context-bar select {
    font-size: 11px;
    padding: 5px 7px;
  }

  .agari-tile-btn {
    width: 36px;
    height: 50px;
  }

  .solo-actions .btn {
    min-width: 100%;
  }

  .solo-hand-tile {
    width: 36px;
    height: 50px;
  }
}
