*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  color-scheme: light dark;
}

:root[data-theme="light"] {
  color-scheme: light;
}

:root[data-theme="dark"] {
  color-scheme: dark;
}

body {
  margin: 0;
  font-family: "LINE Seed JP", sans-serif;
  background: light-dark(#f2f3f7, #282a36);
  color: light-dark(#222, #f8f8f2);
}

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

.theme-toggle {
  position: fixed;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 50;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: 1px solid light-dark(#d1d5db, #555);
  background: light-dark(rgba(255,255,255,0.9), rgba(52,55,70,0.9));
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-shadow: light-dark(0 2px 6px rgba(15,23,42,0.15), 0 2px 6px rgba(0,0,0,0.4));
}

.theme-toggle:hover {
  background: light-dark(#f3f4f6, #44475a);
}

.theme-toggle-icon {
  width: 18px;
  height: 18px;
  color: light-dark(#6b7280, #f1fa8c);
}

.header {
  padding: 1.5rem 1.25rem 0.5rem;
  text-align: center;
  position: relative;
}

.header-room .title {
  margin: 0;
  font-size: 1.7rem;
}

/* ヘッダー右上アクションボタン群（テーマ切替の左に並ぶ） */
.header-actions {
  position: fixed;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.header-action-btn {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: 1px solid light-dark(#d1d5db, #555);
  background: light-dark(rgba(255,255,255,0.9), rgba(52,55,70,0.9));
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 0 0 0 7px;
  overflow: hidden;
  white-space: nowrap;
  transition: width 0.3s ease;
  box-shadow: light-dark(0 2px 6px rgba(15,23,42,0.15), 0 2px 6px rgba(0,0,0,0.4));
  color: light-dark(#6b7280, #ccc);
}

.header-action-btn svg {
  display: block;
  flex-shrink: 0;
}

.header-action-btn:hover {
  width: var(--hover-width, 78px);
  background: light-dark(#f3f4f6, #44475a);
}

.btn-label {
  font-size: 0.75rem;
  margin-left: 4px;
  opacity: 0;
  transition: opacity 0.15s ease 0.15s;
}

.header-action-btn:hover .btn-label {
  opacity: 1;
}

.header-actions .theme-toggle {
  position: static;
}

.header-action-btn--exit {
  margin-left: 0.5rem;
  border: none;
  background: linear-gradient(200deg, #f87171, #dc2626);
  color: #fff;
}

.header-action-btn--exit:hover {
  width: var(--hover-width, 78px);
  background: linear-gradient(200deg, #f98a8a, #e53e3e);
}


.title-char { color: light-dark(#222, #f8f8f2); }
.title-char--green { color: #15ba52; }
.title-char--yellow { color: #dcc00d; }
.title-char--muted { color: light-dark(#aaa, #999); }

.subtitle {
  margin: 0.25rem 0 0;
  font-size: 0.9rem;
  color: light-dark(#555, #b0b0b0);
}

.main {
  flex: 1;
  padding: 1rem 1.25rem 2rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
  max-width: 830px;
  width: 100%;
  margin: 0 auto;
}

@media (min-width: 768px) {
  .main {
    grid-template-columns: minmax(0, 1fr);
  }

  .main .help {
    grid-column: 1 / -1;
  }
}

.panel {
  background: light-dark(#ffffff, #343746);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  box-shadow: light-dark(0 8px 16px rgba(15, 23, 42, 0.08), 0 8px 16px rgba(0, 0, 0, 0.3));
}

.panel-secondary {
  align-self: stretch;
}

.panel-title {
  margin: 0 0 0.75rem;
  font-size: 1.1rem;
}

.panel-text {
  margin: 0 0 1rem;
  font-size: 0.9rem;
  color: light-dark(#444, #ddd);
  line-height: 1.6;
}

.join-form {
  display: flex;
  gap: 0;
  flex-wrap: wrap;
}

.lobby-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.lobby-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.lobby-field .input {
  flex: none;
  max-width: 280px;
}

.lobby-label {
  font-weight: 600;
  color: light-dark(#1f2937, #f8f8f2);
  font-size: 0.85rem;
}

.lobby-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.lobby-actions form {
  display: flex;
}

.lobby-actions form .button {
  flex: 1;
}

.lobby-actions .join-form {
  flex-wrap: nowrap;
}

.lobby-actions .join-form .input {
  flex: 1 1 50%;
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.lobby-actions .join-form .input:focus {
  position: relative;
  z-index: 1;
}

.lobby-actions .join-form .button {
  flex: 0 0 auto;
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  margin-left: -1px;
}

.lobby-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.lobby-divider::before,
.lobby-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: light-dark(#d1d5db, #555);
}

.lobby-divider-text {
  font-size: 0.8rem;
  color: light-dark(#848b96, #999);
  white-space: nowrap;
}

.opponent-nickname-display {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  font-weight: 600;
  color: light-dark(#111827, #f8f8f2);
}

.input {
  flex: 1 1 120px;
  padding: 0.5rem 0.75rem;
  font-size: 1rem;
  border-radius: 8px;
  border: 1px solid light-dark(#cbd5e1, #555);
  background: light-dark(#fff, #44475a);
  color: light-dark(#222, #f8f8f2);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  min-width: 70px;
  padding: 0.55rem 1.1rem;
  font-size: 0.95rem;
  border-radius: 999px;
  border: none;
  background: light-dark(#e5e7eb, #44475a);
  color: light-dark(#111827, #f8f8f2);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, transform 0.05s ease, box-shadow 0.15s ease;
  box-shadow: light-dark(0 2px 4px rgba(15, 23, 42, 0.1), 0 2px 4px rgba(0, 0, 0, 0.3));
}

.button.primary {
  background: linear-gradient(200deg, #55cb96, #329b6a);
  color: #ffffff;
}

.button-warning {
  background: linear-gradient(200deg, #e8c53c, #b69c0b);
  color: #ffffff;
}

.button-danger {
  background: linear-gradient(200deg, #e6637b, #ca3e58);
  color: #ffffff;
}

.button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(15, 23, 42, 0.15);
}

.button:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(15, 23, 42, 0.1);
}

.button:disabled {
  background: light-dark(#ccc, #3a3d4d);
  color: light-dark(#888, #666);
  cursor: default;
  box-shadow: none;
  transform: none;
  pointer-events: none;
}

.button:disabled:hover {
  box-shadow: none;
  transform: none;
}

.button.link-button {
  margin-top: 1rem;
  background: linear-gradient(200deg, #e6637b, #ca3e58);
  color: #ffffff;
  padding-left: 1.5rem;
  border-radius: 0.3rem;
}

.help-list {
  margin: 0.25rem 0 0.75rem 1.25rem;
  padding: 0;
  font-size: 0.9rem;
  color: light-dark(#444, #ddd);
  line-height: 1.6;
}

.help-hint-list {
  list-style: none;
  margin: 0.75rem 0 0.5rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.help-hint-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-left: 0.5rem;
}

.help-hint-text {
  font-size: 0.9rem;
  color: light-dark(#444, #ddd);
}

.help-note {
  margin: 0;
  font-size: 0.8rem;
  color: light-dark(#6b7280, #999);
}

.footer {
  padding: 0.75rem 1.25rem 1rem;
  text-align: center;
  font-size: 0.75rem;
  color: light-dark(#848b96, #aaa);
}

.message {
  max-width: 960px;
  margin: 0 auto;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  font-size: 0.9rem;
}

.message-error {
  background: light-dark(#fee2e2, #44272a);
  color: light-dark(#991b1b, #ff5555);
  border: 1px solid light-dark(#fecaca, #ff5555);
}

.room-code-wrapper {
  margin-top: 0.75rem;
}

.room-code-label {
  display: block;
  font-weight: 600;
  color: light-dark(#1f2937, #f8f8f2);
  font-size: 0.85rem;
  margin-bottom: 0.25rem;
}

.room-code-box {
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  background: light-dark(#f3f4f6, #44475a);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.room-code-input {
  flex: 1 1 auto;
  border: none;
  outline: none;
  background: transparent;
  font-size: 0.95rem;
  color: light-dark(#111827, #f8f8f2);
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
}

.icon-button .icon {
  width: 18px;
  height: 18px;
  fill: light-dark(#6b7280, #999);
}

.icon-button:hover .icon {
  fill: light-dark(#374151, #f8f8f2);
}

.icon-button .icon.icon-clipboard {
  fill: none;
  stroke: currentColor;
  color: light-dark(#6b7280, #999);
}

.icon-button:hover .icon.icon-clipboard {
  color: light-dark(#374151, #f8f8f2);
}

.copy-status {
  font-size: 0.75rem;
  color: light-dark(#6b7280, #999);
}

.match-status {
  margin-top: 0.75rem;
  font-size: 0.9rem;
  color: light-dark(#374151, #ddd);
}

.match-status-label {
  font-weight: 600;
}

.phase {
  margin-top: 1.25rem;
}

.phase-playing {
  position: relative;
  padding-bottom: 400px;
}

.phase-confirming {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.ready-button {
  min-width: 180px;
  justify-content: center;
}

.phase-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: light-dark(#111827, #f8f8f2);
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
}

.turn-timer {
  font-size: 0.95rem;
  color: light-dark(#374151, #ddd);
}

.turn-timer--danger {
  color: #b91c1c;
  font-weight: 700;
}

.phase-note {
  margin: 0.35rem 0 0;
  font-size: 0.85rem;
  color: light-dark(#6b7280, #999);
  text-align: center;
}

/* Options section */
.options-section {
  width: 100%;
  max-width: 320px;
  margin: 0.5rem auto 0.75rem;
  padding: 0.75rem 1rem;
  background: light-dark(#f9fafb, #3a3d4d);
  border: 1px solid light-dark(#e5e7eb, #555);
  border-radius: 0.5rem;
}

.options-title {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
  font-weight: 600;
  text-align: center;
  color: light-dark(#374151, #f8f8f2);
}

.options-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.4rem;
}

.options-label {
  font-size: 0.85rem;
  color: light-dark(#4b5563, #ddd);
}

.options-select {
  padding: 0.3rem 0.5rem;
  font-size: 0.85rem;
  border: 1px solid light-dark(#d1d5db, #555);
  border-radius: 0.375rem;
  background: light-dark(#fff, #44475a);
  color: light-dark(#111827, #f8f8f2);
  cursor: pointer;
}

.options-select:disabled {
  background: light-dark(#f3f4f6, #3a3d4d);
  color: light-dark(#848b96, #aaa);
  cursor: not-allowed;
}

.options-stepper {
  display: flex;
  align-items: center;
  gap: 0;
}

.options-stepper-btn {
  width: 2rem;
  height: 2rem;
  border: 1px solid light-dark(#d1d5db, #555);
  background: light-dark(#fff, #44475a);
  color: light-dark(#374151, #f8f8f2);
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  line-height: 1;
}

.options-stepper-btn:first-child {
  border-radius: 0.375rem 0 0 0.375rem;
  border-right: none;
}

.options-stepper-btn:last-child {
  border-radius: 0 0.375rem 0.375rem 0;
  border-left: none;
}

.options-stepper-btn:disabled {
  background: light-dark(#f3f4f6, #3a3d4d);
  color: light-dark(#848b96, #aaa);
  cursor: not-allowed;
}

.options-stepper-input {
  width: 3rem;
  height: 2rem;
  border: 1px solid light-dark(#d1d5db, #555);
  background: light-dark(#fff, #44475a);
  color: light-dark(#111827, #f8f8f2);
  font-size: 0.85rem;
  text-align: center;
  border-radius: 0;
  -moz-appearance: textfield;
  appearance: textfield;
}

.options-stepper-input::-webkit-inner-spin-button,
.options-stepper-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.options-stepper-input:disabled {
  background: light-dark(#f3f4f6, #3a3d4d);
  color: light-dark(#848b96, #aaa);
  cursor: not-allowed;
}

.options-note {
  margin: 0.3rem 0 0;
  font-size: 0.78rem;
  color: light-dark(#848b96, #aaa);
  text-align: center;
}

/* 手牌入力 */
.hand-input-section {
  margin-top: 1rem;
}

.hand-eval {
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  min-height: 1.4em;
  text-align: center;
}

.hand-eval--agari {
  color: light-dark(#0d823a, #24b95d);
  font-weight: 600;
}

.hand-eval--shanten {
  color: light-dark(#b91c1c, #ec4747);
  font-weight: 600;
}

/* 回答判定スキャン演出: Before/Afterレイヤー切替 */
.hand-slot--before-scan {
  filter: brightness(0.85);
}

.scan-line {
  position: absolute;
  top: -4px;
  bottom: -4px;
  width: 48px;
  z-index: 10;
  pointer-events: none;
  background: linear-gradient(90deg,
    transparent,
    rgba(240, 254, 254, 0.08) 20%,
    rgba(240, 254, 254, 0.25) 38%,
    rgba(240, 254, 254, 0.5) 45%,
    #F0FEFE 49%,
    #F0FEFE 51%,
    rgba(240, 254, 254, 0.5) 55%,
    rgba(240, 254, 254, 0.25) 62%,
    rgba(240, 254, 254, 0.08) 80%,
    transparent
  );
  border-radius: 2px;
  animation: scan-line-move 1.2s forwards;
}

@keyframes scan-clip {
  0%   { clip-path: inset(0 0 0 0%); }
  100% { clip-path: inset(0 0 0 100%); }
}

@keyframes scan-line-move {
  0%      { left: -24px; opacity: 1; animation-timing-function: ease-out; }
  91.67%  { left: calc(100% - 24px); opacity: 1; animation-timing-function: linear; }
  100%    { left: calc(100% - 24px); opacity: 0; }
}

.hand-label {
  margin: 0.5rem 0;
  font-size: 0.9rem;
  color: light-dark(#374151, #ddd);
}

.hand-slots {
  display: flex;
  flex-wrap: nowrap;
  gap: 2px;
  margin-bottom: 1rem;
  min-height: 47px;
}

.hand-slot {
  width: 36px;
  min-width: 36px;
  height: 47px;
  border: 2px solid light-dark(#88888888, #aaaaaa88);
  border-radius: 6px;
  background: light-dark(#f9fafb, #44475a);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  overflow: hidden;
  position: relative;
}

.hand-slot img,
.hand-slot svg {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: contain;
  -webkit-user-drag: none;
  user-select: none;
}

.hand-slot--cursor {
  border: 2px dashed light-dark(#b0b8c1, #777);
  background: light-dark(#f3f4f6, #3a3d4d);
  box-shadow: 0 0 0 1px light-dark(rgba(176, 184, 193, 0.3), rgba(119, 119, 119, 0.3));
}

.hand-slot-ron-wrap {
  position: relative;
  width: 36px;
  min-width: 36px;
  height: 47px;
  flex-shrink: 0;
  margin-left: 20px;
}

.hand-slot-ron-wrap .hand-slot {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
}

.hand-slot-ron-label {
  position: absolute;
  top: -0.95em;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 0.65rem;
  font-weight: 600;
  color: light-dark(#6b7280, #999);
  line-height: 1;
  white-space: nowrap;
}

/* ドラッグ&ドロップ理牌 */
.hand-slot--drag-clone {
  position: fixed;
  z-index: 200;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
  opacity: 0.92;
  pointer-events: none;
  border: 2px solid light-dark(#b0b8c1, #777);
  border-radius: 6px;
  background: light-dark(#f9fafb, #44475a);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.hand-slot--drag-clone img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.hand-slots--reordering .guess-slot {
  cursor: grabbing;
}

.time-up-history {
  margin-left: 0 !important;
  width: 100px !important;
  border: none !important;
}

.sp-history {
  margin-left: 0 !important;
  width: 180px !important;
  border: none !important;
  color: light-dark(#7c3aed, #d1c1ff);
  font-weight: 600;
}

/* SP ボタン */
.button-sp {
  background: linear-gradient(200deg, #a78bfa, #7c3aed);
  color: #fff;
  min-width: 48px;
}

/* SP ルーレット */
.sp-roulette {
  padding: 0.5rem 0.5rem 0;
  margin: 20px;
}

.sp-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 0.5rem;
}

.sp-card {
  height: 80px;
  border-radius: 8px;
  border: 2px solid light-dark(#d1d5db, #555);
  background: light-dark(#f9fafb, #44475a);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 1rem;
  transition: border-color 0.1s, background 0.1s;
  user-select: none;
}

.sp-card--active {
  border-color: #7c3aed;
  background: light-dark(#ede9fe, #5b4a8a);
}

.sp-card--flip {
  color: light-dark(#7c3aed, #d1c1ff);
  font-size: 0.85rem;
  word-break: break-all;
  padding: 4px;
}

.sp-roulette-buttons {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 40px;
}

.sp-info-text {
  color: #0d823a;
  font-weight: 600;
}

.tile-picker {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tile-picker-row {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
}

.tile-picker-tile {
  width: 36px;
  height: 47px;
  border: 1px solid light-dark(#e5e7eb, #555);
  border-radius: 3px;
  padding: 0;
  background: light-dark(#fff, #44475a);
  cursor: pointer;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s, border-color 0.15s;
}

.tile-picker-tile:hover:not(.tile-picker-tile--disabled) {
  border-color: #3b82f6;
}

.tile-picker-tile img,
.tile-picker-tile svg {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.tile-picker-tile--disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.tile-picker-delete {
  align-self: center;
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
  border: 1px solid #bbb;
  border-radius: 5px;
  background: #555;
  color: #eee;
  cursor: pointer;
  margin-left: 4px;
}

.tile-picker-delete:hover {
  background: #777;
  border-color: #ccc;
}

.game-scores {
  margin: 0 0 1rem 0;
  text-align: center;
}

.scoreboard-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
}

.scoreboard-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: light-dark(#111827, #f8f8f2);
}

.scoreboard-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  height: 2rem;
  padding: 0 0.4rem;
  border-radius: 6px;
  background: light-dark(#4b5563, #f8f8f2);
  color: light-dark(#fff, #282a36);
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1;
}

.scoreboard-sep {
  font-size: 1rem;
  font-weight: 700;
  color: light-dark(#4b5563, #999);
}

.scoreboard-sub {
  margin-top: 0.15rem;
  font-size: 0.78rem;
  color: light-dark(#40444d, #ccc);
}

.input-panel {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 360px;
  z-index: 99;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  pointer-events: none;
}

.input-panel-inner {
  position: relative;
  width: min(800px, 100% - 3rem);
  height: 100%;
  margin: 0 auto;
  padding: 0.75rem 1rem 2.25rem;
  border-radius: 16px 16px 0 0;
  background: light-dark(rgba(200, 200, 200, 0.3), rgba(67, 65, 72, 0.3));
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: light-dark(0 -8px 24px rgba(15, 23, 42, 0.25), 0 -8px 24px rgba(0, 0, 0, 0.5));
  border: 1px solid light-dark(#d1d5db, #555);
  border-bottom: none;
  pointer-events: auto;
  box-sizing: border-box;
}

.input-panel-inner--disabled .tile-picker,
.input-panel-inner--disabled .input-main-button-row {
  opacity: 0.4;
}


.input-panel--collapsed {
  transform: translateY(calc(100% - 100px));
}

.input-panel {
  transition: transform 0.2s ease-out;
}

.hand-building-panel {
  background: light-dark(#f3f4f6, #3a3d4d);
  border-radius: 12px;
  padding: 0.75rem 0.9rem 1rem;
  margin: 0.5rem 0 1rem;
  max-width: 100%;
}

.hand-build-row {
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  gap: 0.75rem;
}

.input-main-row {
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  gap: 0.75rem;
}

.hand-set-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0 0 1.25rem 0;
  flex-shrink: 0;
}

.input-main-button-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0 0 1.25rem 0;
  flex-shrink: 0;
}

.input-panel-toggle {
  position: absolute;
  left: 50%;
  top: -0.8rem;
  transform: translateX(-50%);
  padding: 0 50px;
  height: 24px;
  border-radius: 999px;
  border: 1px solid light-dark(#d1d5db, #555);
  background: light-dark(#f3f3f3, #46475a);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.8rem;
  color: light-dark(#4b5563, #ccc);
  box-shadow: light-dark(0 2px 6px rgba(15, 23, 42, 0.2), 0 2px 6px rgba(0, 0, 0, 0.4));
}

.input-panel-toggle:hover {
  background: light-dark(#f9fafb, #575b71);
}

.hand-set-note {
  font-size: 0.85rem;
  color: light-dark(#6b7280, #999);
  text-align: center;
}

.button-set-hand {
  flex-shrink: 0;
}

.hand-slots--readonly .hand-slot {
  cursor: default;
}

.answer-turn-block .hand-label {
  margin-top: 0.75rem;
}

.answer-turn-block .hand-label:first-of-type {
  margin-top: 0;
}

.guess-input-panel {
  background: light-dark(#f3f4f6, #3a3d4d);
  border-radius: 12px;
  padding: 0.75rem 1rem;
  margin: 0.5rem 0 1rem;
  max-width: 100%;
}

.guess-row {
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  gap: 0.75rem;
}

.input-panel-footer {
  margin: 0 calc(2.8rem + 6px - 1rem) 0;
}

/* 入力パネル内の牌入力キーを左右中央揃え */
.input-panel-footer .tile-picker {
  align-items: center;
}

.input-panel-footer .tile-picker-row {
  justify-content: center;
}

.answer-turn-note {
  margin: 0.3rem 0 0.5rem;
  font-size: 0.9rem;
  color: light-dark(#374151, #ddd);
  text-align: center;
}

.guess-submit-row {
  margin: 0 0 1.25rem 0;
}

.guess-slots .hand-slot--hit {
  border-color: rgb(21, 186, 82);
  box-shadow: 0 0 0 1px rgba(22, 176, 78, 0.3);
}

.guess-slots .hand-slot--blow {
  border-color: rgb(238, 192, 13);
  box-shadow: 0 0 0 1px rgba(220, 192, 13, 0.3);
}

.guess-slots--opponent {
  opacity: 0.5;
  pointer-events: none;
}

.answer-history-section {
  margin-top: 1.25rem;
}

.answer-history-section .hand-label {
  margin-bottom: 0.35rem;
}

.answer-history {
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}

.answer-history-row {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  align-items: center;
}

.answer-history-row-label {
  flex: 0 0 auto;
  font-size: 0.8rem;
  color: light-dark(#6b7280, #999);
  width: 3.5em;
}

.answer-history-row-tiles {
  display: flex;
  flex-wrap: nowrap;
  gap: 2px;
  pointer-events: none;
}

.answer-history-row .hand-slot--hit {
  border-color: rgb(21, 186, 82);
}

.answer-history-row .hand-slot--blow {
  border-color: rgb(238, 192, 13);
}

.answer-tabs {
  margin: 1.5rem auto 0;
  display: flex;
  gap: 0.5rem;
  border-bottom: 1px solid light-dark(#e5e7eb, #555);
  max-width: 800px;
}

.answer-tab-button {
  padding: 0.4rem 0.9rem;
  font-size: 0.9rem;
  border: none;
  background: transparent;
  cursor: pointer;
  color: light-dark(#6b7280, #999);
  border-bottom: 2px solid transparent;
}

.answer-tab-button--active {
  color: light-dark(#111827, #f8f8f2);
  font-weight: 600;
  border-bottom-color: light-dark(#2563eb, #bd93f9);
}

.answer-tabs-body {
  margin-top: 0.75rem;
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
}

.answer-tab-panel {
  display: none;
}

.answer-tab-panel--active {
  display: block;
}

.answer-tab-hand {
  margin-bottom: 0.75rem;
}

.answer-tab-hand .hand-slots {
  margin-left: calc(2.8rem + 6px);
}

.my-hand-bottom {
  margin-top: 1.25rem;
  padding-top: 0.75rem;
  border-top: 1px solid light-dark(#e5e7eb, #555);
}

.my-hand-bottom .hand-label--compact {
  font-size: 0.85rem;
  color: light-dark(#6b7280, #999);
  margin-bottom: 0.25rem;
}

/* 回答エリア3種の1牌目横位置を揃える（巡目ラベル幅 3.5em=2.8rem @ 0.8rem + gap 6px） */
.hand-build-row .hand-slots {
  margin-left: calc(2.8rem + 6px);
}

/* input-panel-innerのpadding: 1remを差し引いてanswer-tab-hand / answer-historyと揃える */
.guess-slots {
  margin-left: calc(2.8rem + 6px - 1rem);
  touch-action: none;
  user-select: none;
}

.my-hand-bottom .hand-slots {
  margin-left: calc(2.8rem + 6px);
}

/* ロン牌のスペースを履歴・自分の手牌にも統一的に付与 */
.answer-history-row-tiles .hand-slot:last-child,
.my-hand-bottom .hand-slots .hand-slot:last-child,
.answer-tab-hand .hand-slots .hand-slot:last-child {
  margin-left: 20px;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
}

.modal-particles {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 42;
  pointer-events: none;
}

.modal-dialog {
  position: relative;
  z-index: 201;
  background: light-dark(#ffffff, #343746);
  border-radius: 12px;
  padding: 1.5rem 1.75rem;
  max-width: 480px;
  width: calc(100% - 2rem);
  box-shadow: light-dark(0 20px 40px rgba(15, 23, 42, 0.35), 0 20px 40px rgba(0, 0, 0, 0.6));
  text-align: center;
}

.modal-dialog > .button,
.modal-dialog > .exit-confirm-buttons {
  margin-top: 2rem;
}

.modal-title {
  margin: 0 0 0.75rem;
  font-size: 1.2rem;
  font-weight: 700;
  color: light-dark(#111827, #f8f8f2);
}

.modal-hand {
  margin: 0 0 0.75rem;
  display: flex;
  justify-content: center;
  gap: 1px;
}

.modal-opponent-label {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  color: light-dark(#6b7280, #999);
}

.modal-hand .hand-slot {
  width: 27px;
  min-width: 27px;
  height: 36px;
}

.modal-note {
  margin: 0 0 1rem;
  font-size: 0.9rem;
  color: light-dark(#4b5563, #ddd);
}

/* 遊び方モーダル（.modal-dialog の後に定義して max-width を上書き） */
.help-modal-dialog {
  max-width: 800px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.help-modal-body {
  overflow-y: auto;
  text-align: left;
  margin-bottom: 1rem;
}

.help-modal-body .help-list {
  padding-left: 1.25rem;
  margin: 0;
}

.help-modal-body .help-list li {
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  line-height: 1.6;
}

.help-modal-body .help-note {
  font-size: 0.8rem;
  color: light-dark(#6b7280, #999);
  margin: 0.75rem 0 0;
  line-height: 1.6;
}

.exit-confirm-note {
  color: light-dark(#6c5f99, #b0aecc);
}

/* 退出確認モーダル（.button より後に定義） */
.exit-confirm-buttons {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
}

.exit-confirm-buttons .button {
  flex: 1;
  max-width: 160px;
}

.exit-confirm-buttons .button:not(.button-danger-exit) {
  background: transparent;
  box-shadow: none;
  border: 1px solid light-dark(#d1d5db, #555);
}

.button-danger-exit {
  background: linear-gradient(200deg, #f87171, #dc2626);
  color: #fff;
}

.hand-slot--blow::before {
  content: "";
  position: absolute;
  inset: 0;
  background:linear-gradient(-135deg,
    #eec00d11 0 82%, #eec00d 82% 100%
    ) top right;
  background-size: 100% 100%;
  background-repeat: no-repeat;
  pointer-events: none;
  z-index: 2;
}

/* Hit を Blow より視覚的に強調するためのコーナー装飾 */
.hand-slot--hit::before {
  content: "";
  position: absolute;
  inset: 0;
  /* background:linear-gradient(-135deg, #22c55e 0 13%, transparent 13% 87%, #22c55e 87% 100%) top right; */
  background:linear-gradient(-135deg,
    #15ba52 0 18%, #22c55e11 18% 82%, #15ba52 82% 100%
    ) top right;
  background-size: 100% 100%;
  background-repeat: no-repeat;
  pointer-events: none;
  z-index: 2;
}

.pop-in {
  animation: pop-in 0.12s ease-out;
}

@keyframes pop-in {
  0% {
    transform: scale(0.7);
    opacity: 0;
  }
  60% {
    transform: scale(1.15);
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}