  /* Chakra UI 스타일 참고: 아이보리 배경 + 흰 카드 + teal 포인트 */
  :root {
    --bg: #FBF7EC;
    --card: #FFFFFF;
    --card-soft: #FDFBF3;
    --secondary-btn: #EEE8D8;
    --secondary-btn-hover: #E2D8C0;
    --text: #1A202C;
    --muted: #718096;
    --accent: #319795;
    --accent-deep: #2C7A7B;
    --accent-soft: #E6FFFA;
    --positive: #38A169;
    --negative: #E53E3E;
    --line: #E2E8F0;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
    --focus-ring: 0 0 0 3px rgba(49, 151, 149, 0.35);
  }
  * { margin: 0; padding: 0; box-sizing: border-box; }
  .screen-ripple {
    position: fixed;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 1px solid rgba(49, 151, 149, 0.1);
    background: radial-gradient(
      circle,
      rgba(44, 122, 123, 0.58) 0%,
      rgba(49, 151, 149, 0.34) 30%,
      rgba(49, 151, 149, 0.14) 64%,
      rgba(49, 151, 149, 0.025) 100%
    );
    box-shadow: inset 0 0 24px rgba(49, 151, 149, 0.06);
    pointer-events: none;
    transform: scale(1);
    opacity: 1;
    animation: screen-ripple 760ms cubic-bezier(.16, 1, .3, 1) forwards;
    z-index: 9999;
  }
  .screen-ripple::before,
  .screen-ripple::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    border: 1px solid rgba(49, 151, 149, 0.1);
  }
  .screen-ripple::before { inset: 16%; }
  .screen-ripple::after { inset: 32%; }
  @keyframes screen-ripple {
    to { transform: scale(12); opacity: 0; }
  }
  @media (prefers-reduced-motion: reduce) {
    .screen-ripple { animation-duration: 1ms; }
  }
  body {
    background: var(--bg);
    color: var(--text);
    font-family: "Pretendard", sans-serif;
    min-height: 100vh;
  }
  /* 게임 선택 이후에도 최초 게임 선택 화면과 동일한 아이보리 배경을 유지한다. */
  body[data-game] { background: var(--bg); }
  .container { max-width: 640px; margin: 0 auto; padding: 20px 16px 60px; position: relative; z-index: 1; }
  /* 게임별 캐릭터 배경 워터마크. 뷰포트에 고정되어 스크롤해도 흔들리지 않는다. */
  .game-bg {
    position: fixed;
    bottom: 5vh;
    left: 50%;
    width: 50vw;
    height: 50vh;
    transform: translateX(-50%);
    background-repeat: no-repeat;
    background-position: center bottom;
    background-size: contain;
    pointer-events: none;
    z-index: 0;
    opacity: 0;
    transition: opacity .25s ease;
  }
  .game-bg[data-active="skullking"] {
    opacity: 0.3;
    background-image: url("assets/bg-skullking.png");
  }
  .game-bg[data-active="tichu"] {
    opacity: 0.3;
    background-image: url("assets/bg-tichu.png");
  }

  /* 좌측 상단 햄버거 메뉴 + 사이드 드로어 */
  .menu-toggle {
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 5;
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: var(--card);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    cursor: pointer;
    touch-action: manipulation;
  }
  .menu-toggle:focus-visible { outline: none; box-shadow: var(--focus-ring); }
  .menu-toggle span { display: block; width: 18px; height: 2px; background: var(--text); border-radius: 1px; }
  .side-menu-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(26, 32, 44, 0.35);
    z-index: 19;
    display: none;
  }
  .side-menu-backdrop.show { display: block; }
  .side-menu {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(78vw, 300px);
    background: var(--card);
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.12);
    z-index: 20;
    transform: translateX(-100%);
    transition: transform .25s ease;
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  .side-menu.open { transform: translateX(0); }
  .side-menu-header { font-weight: 700; font-size: 1.05rem; margin-bottom: 8px; }
  .side-menu-item {
    text-align: left;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: var(--card-soft);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
    touch-action: manipulation;
  }
  .side-menu-item:hover:not(:disabled) { border-color: var(--accent); }
  .side-menu-item:focus-visible { outline: none; box-shadow: var(--focus-ring); }
  .side-menu-item:disabled { color: var(--muted); cursor: not-allowed; opacity: .6; }
  header { text-align: center; padding: 24px 0 8px; }
  header h1 { font-size: 1.5rem; letter-spacing: 0.5px; }
  header p { color: var(--muted); font-size: 0.85rem; margin-top: 6px; }
  .screen { display: none; }
  .screen.active { display: block; }
  .card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 18px;
    margin-top: 16px;
  }
  .card h2 { font-size: 1.05rem; margin-bottom: 12px; }
  .mode-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 4px; }
  .screen > .mode-buttons { margin-top: 20px; }
  .mode-btn {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow);
    color: var(--text);
    padding: 26px 12px;
    font-size: 1.15rem;
    font-weight: 700;
    cursor: pointer;
    transition: border-color .15s, box-shadow .15s, transform .1s;
  }
  .mode-btn small { display: block; font-weight: 400; color: var(--muted); font-size: 0.8rem; margin-top: 8px; }
  .mode-btn:hover { border-color: var(--accent); }
  .mode-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
  .mode-btn:active { transform: scale(0.98); }
  .chip-list { display: flex; flex-wrap: wrap; gap: 8px; }
  .chip {
    border: 1px solid var(--line);
    background: var(--card);
    color: var(--text);
    border-radius: 999px;
    padding: 9px 16px;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background .15s, border-color .15s, color .15s;
    touch-action: manipulation;
  }
  .chip:focus-visible { outline: none; box-shadow: var(--focus-ring); }
  .chip.selected {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent-deep);
    font-weight: 700;
  }
  .guest-row { display: flex; gap: 8px; margin-top: 12px; }
  .guest-row input,
  .extra-bonus-input,
  select.call-select {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text);
    padding: 10px 12px;
    font-size: 1rem;
  }
  .guest-row input { flex: 1; }
  .guest-row input:focus, .extra-bonus-input:focus, select.call-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: var(--focus-ring);
  }
  .btn {
    background: var(--accent);
    color: #FFFFFF;
    border: none;
    border-radius: 8px;
    padding: 12px 18px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: var(--shadow);
    touch-action: manipulation;
  }
  .btn:hover { background: var(--accent-deep); }
  .btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
  .btn.ghost {
    background: var(--secondary-btn);
    color: #5F584A;
    border: 1px solid var(--secondary-btn-hover);
    box-shadow: var(--shadow);
    font-weight: 500;
  }
  .btn.ghost:hover {
    background: var(--secondary-btn-hover);
    color: var(--text);
  }
  .btn.block { display: block; width: 100%; margin-top: 16px; }
  .hint { color: var(--muted); font-size: 0.82rem; margin-top: 10px; line-height: 1.5; }
  .error { color: var(--negative); font-size: 0.85rem; margin-top: 10px; display: none; }
  .error.show { display: block; }
  .top-row { display: flex; justify-content: space-between; align-items: center; margin-top: 16px; gap: 8px; }
  .round-badge { font-size: 1.1rem; font-weight: 700; }
  .round-badge span { color: var(--accent-deep); }
  .round-sub { color: var(--muted); font-size: 0.8rem; margin-top: 5px; }
  .custom-mode-panel {
    margin-top: 16px;
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: var(--shadow);
  }
  .custom-check-row {
    display: flex;
    align-items: center;
    gap: 9px;
    color: var(--text);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
  }
  .custom-check-row input {
    width: 19px;
    height: 19px;
    accent-color: var(--accent);
    flex-shrink: 0;
  }
  .custom-mode-options {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
  }
  .custom-round-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    color: var(--muted);
    font-size: 0.85rem;
  }
  .custom-round-stepper { width: 150px; }
  .custom-round-stepper button:disabled { color: var(--line); cursor: not-allowed; }
  .auto-round-check { margin-top: 12px; font-weight: 500; }
  table.score-board { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
  table.score-board th, table.score-board td { padding: 8px 6px; text-align: center; border-bottom: 1px solid var(--line); white-space: nowrap; }
  table.score-board th { color: var(--muted); font-weight: 500; font-size: 0.8rem; }
  table.score-board td.name { text-align: left; font-weight: 600; }
  .total-pos { color: var(--positive); font-weight: 700; }
  .total-neg { color: var(--negative); font-weight: 700; }
  .rank-1 .name::after { content: " 👑"; }
  .player-entry {
    background: var(--card-soft);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 14px;
    margin-top: 12px;
  }
  .player-entry .p-name { font-weight: 700; margin-bottom: 10px; }
  .entry-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .entry-grid .bonus-field { grid-column: 1 / -1; }
  .entry-grid label, .field-label { display: block; color: var(--muted); font-size: 0.75rem; margin-bottom: 8px; }
  .stepper {
    display: flex;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
    background: var(--card);
  }
  .stepper button {
    background: var(--card);
    border: none;
    color: var(--text);
    min-width: 44px;
    height: 44px;
    font-size: 1.05rem;
    cursor: pointer;
    flex-shrink: 0;
    touch-action: manipulation;
  }
  .stepper button:hover { background: var(--accent-soft); color: var(--accent-deep); }
  .stepper button:active { background: var(--line); }
  .stepper .val { flex: 1; text-align: center; font-size: 1rem; font-weight: 600; min-width: 44px; }
  .bonus-note { color: var(--muted); font-size: 0.72rem; margin-top: 12px; line-height: 1.5; }
  .bonus-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
  .bonus-row .bonus-label { font-size: 0.78rem; color: var(--muted); }
  .extra-bonus-input { width: 132px; text-align: center; }
  .preview { margin-top: 14px; font-size: 0.85rem; color: var(--muted); line-height: 1.5; }
  .preview b.pos { color: var(--positive); }
  .preview b.neg { color: var(--negative); }
  .team-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
  .team-box {
    background: var(--card-soft);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 12px;
    min-height: 108px;
  }
  .team-box h3 { font-size: 0.85rem; color: var(--accent-deep); margin-bottom: 8px; }
  .team-box .chip { display: block; width: 100%; text-align: center; margin-bottom: 6px; }
  .call-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 12px; }
  .call-row .call-name { font-size: 0.9rem; font-weight: 600; }
  select.call-select { min-width: 132px; }
  .result-banner { text-align: center; padding: 10px 0 4px; }
  .result-banner .winner { font-size: 1.25rem; font-weight: 800; color: var(--accent-deep); margin-top: 4px; }
  details.rules {
    margin-top: 16px;
    color: var(--muted);
    font-size: 0.83rem;
    border-radius: 12px;
  }
  details.rules summary {
    cursor: pointer;
    color: var(--text);
    font-size: 0.9rem;
    padding: 10px 12px;
    background: var(--secondary-btn);
    border: 1px solid var(--secondary-btn-hover);
    border-radius: 8px;
    box-shadow: var(--shadow);
  }
  details.rules[open] {
    padding: 12px 14px 14px;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
  }
  details.rules[open] summary {
    background: var(--card-soft);
    border-color: var(--line);
    box-shadow: none;
  }
  details.rules ul { margin: 12px 0 0 18px; line-height: 1.7; }
  .footer-actions { display: flex; gap: 10px; margin-top: 20px; }
  .footer-actions .btn { flex: 1; }
  .modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(26, 32, 44, 0.45);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 30;
    padding: 20px;
  }
  .modal-overlay.show { display: flex; }
  .modal-box {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    padding: 24px 18px;
    max-width: 320px;
    width: 100%;
    text-align: center;
  }
  .modal-box p { line-height: 1.6; font-weight: 600; }
  .modal-box .sub { color: var(--muted); font-size: 0.85rem; margin-top: 8px; font-weight: 400; }
  .modal-actions { display: flex; gap: 10px; margin-top: 20px; }
  .modal-actions .btn { flex: 1; }
  .edit-rounds-box {
    max-width: min(92vw, 640px);
    max-height: 86vh;
    overflow-y: auto;
    text-align: left;
  }
  .edit-rounds-box h2 { font-size: 1.05rem; }
  .round-edit-scroll {
    overflow-x: auto;
    margin-top: 16px;
    border: 1px solid var(--line);
    border-radius: 10px;
  }
  .round-edit-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
  }
  .round-edit-table th,
  .round-edit-table td {
    padding: 8px 6px;
    text-align: center;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
  }
  .round-edit-table tr:last-child td { border-bottom: none; }
  .round-edit-table th {
    color: var(--muted);
    background: var(--card-soft);
    font-weight: 600;
  }
  .round-edit-table th:first-child,
  .round-edit-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 1;
    min-width: 88px;
    text-align: left;
    background: var(--card);
    font-weight: 600;
  }
  .round-edit-table th:first-child { background: var(--card-soft); }
  .round-score-input {
    width: 76px;
    padding: 9px 6px;
    border: 1px solid var(--line);
    border-radius: 7px;
    color: var(--text);
    background: var(--card);
    font-size: 0.95rem;
    text-align: center;
  }
  .round-score-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: var(--focus-ring);
  }
  /* 아이폰 SE(375px)~16 Pro Max(440px) 등 좁은 화면 최적화. 태블릿 이상은 웹과 동일. */
  @media (max-width: 480px) {
    .container { padding: 12px 10px 48px; }
    header h1 { font-size: 1.25rem; }
    .card { padding: 14px 12px; }
    .mode-btn { padding: 22px 8px; font-size: 1.05rem; }
    .chip { padding: 9px 13px; font-size: 0.9rem; }
    table.score-board { font-size: 0.85rem; }
    table.score-board th, table.score-board td { padding: 7px 5px; }
  }
