/* style.css — スマホ最適化 麻雀精算アプリ */

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

:root {
  --bg:        #f4f4f6;
  --surface:   #ffffff;
  --border:    #e2e2e6;
  --text:      #1a1a1e;
  --muted:     #6b6b78;
  --primary:   #4f46e5;
  --primary-l: #eef2ff;
  --success:   #16a34a;
  --success-l: #dcfce7;
  --danger:    #dc2626;
  --danger-l:  #fee2e2;
  --warn:      #d97706;
  --warn-l:    #fef3c7;
  --info:      #0284c7;
  --info-l:    #e0f2fe;
  --radius:    12px;
  --radius-sm: 8px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:      #0f0f12;
    --surface: #1c1c21;
    --border:  #2e2e36;
    --text:    #e8e8f0;
    --muted:   #8888a0;
  }
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom);
}

/* ── Screens ─────────────────────────────────── */
.screen { display: flex; flex-direction: column; min-height: 100dvh; }
.hidden { display: none !important; }

.top-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 16px 12px;
  position: sticky; top: 0; z-index: 10;
}
.top-bar h1 { font-size: 17px; font-weight: 600; }
.top-bar .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

.content { flex: 1; padding: 16px; display: flex; flex-direction: column; gap: 12px; }

/* ── Cards ───────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.card-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 10px;
}

/* ── Buttons ─────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 48px; padding: 0 20px;
  font-size: 15px; font-weight: 500;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: opacity .15s;
  width: 100%;
}
.btn:active { opacity: .7; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-sm { height: 36px; font-size: 13px; width: auto; padding: 0 14px; }
.btn-icon {
  background: none; border: none; cursor: pointer; font-size: 16px;
  padding: 4px 8px; color: var(--muted);
  -webkit-tap-highlight-color: transparent;
}

/* ── Home screen ─────────────────────────────── */
#screen-home .content {
  justify-content: center;
  align-items: center;
  text-align: center;
  padding-top: 60px;
}
.app-icon { font-size: 56px; margin-bottom: 12px; }
.app-title { font-size: 24px; font-weight: 700; margin-bottom: 4px; }
.app-sub   { font-size: 14px; color: var(--muted); margin-bottom: 32px; }
.home-btns { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 320px; }

/* ── Forms ───────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.form-group label { font-size: 13px; font-weight: 500; color: var(--muted); }
.form-group input,
.form-group select,
.form-group textarea {
  height: 44px;
  padding: 0 12px;
  font-size: 15px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  width: 100%;
}
.form-group textarea { height: 110px; padding: 10px 12px; resize: none; line-height: 1.6; }
.form-hint { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ── Score table ─────────────────────────────── */
.score-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.score-table th {
  font-weight: 500; font-size: 11px; color: var(--muted);
  padding: 6px 4px; border-bottom: 1px solid var(--border);
  text-align: left;
}
.score-table td { padding: 9px 4px; border-bottom: 1px solid var(--border); }
.score-table tr:last-child td { border-bottom: none; }
.score-table .c { text-align: center; }
.pos { color: var(--success); }
.neg { color: var(--danger); }

/* ── Payment rows ────────────────────────────── */
.payment-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.payment-row:last-child { border-bottom: none; }
.arrow { color: var(--muted); }

/* ── Badges ──────────────────────────────────── */
.badge {
  display: inline-block; font-size: 12px; font-weight: 500;
  padding: 3px 10px; border-radius: 999px;
}
.badge-info { background: var(--info-l); color: var(--info); }
.badge-warn { background: var(--warn-l); color: var(--warn); }

/* ── Game history cards ──────────────────────── */
.game-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 10px;
  overflow: hidden;
}
.game-header {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.game-no   { font-weight: 600; }
.game-time { color: var(--muted); flex: 1; }
.game-results { padding: 8px 14px; }
.game-result-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.game-result-row:last-child { border-bottom: none; }
.rank {
  font-size: 11px; font-weight: 600; padding: 2px 7px;
  border-radius: 999px; min-width: 34px; text-align: center;
}
.rank-1 { background: #fef9c3; color: #854d0e; }
.rank-2 { background: #f1f5f9; color: #475569; }
.rank-3 { background: #fff7ed; color: #9a3412; }
.rank-4 { background: #f8fafc; color: #64748b; }
.pname     { flex: 1; }
.score-raw { color: var(--muted); font-size: 13px; }
.score-pt  { font-weight: 600; min-width: 50px; text-align: right; }

/* ── Score input screen ──────────────────────── */
.input-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.input-row:last-child { border-bottom: none; }
.input-row label  { flex: 1; font-size: 15px; }
.input-row input  { width: 110px; height: 44px; padding: 0 10px; font-size: 16px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); text-align: right; }
.pt-label { font-size: 13px; color: var(--muted); min-width: 18px; }

.check-ok { font-size: 13px; color: var(--success); padding: 6px 0; }
.check-ng { font-size: 13px; color: var(--danger);  padding: 6px 0; }

/* ── Settings ────────────────────────────────── */
.settings-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.settings-row:last-child { border-bottom: none; }
.settings-row label { font-size: 14px; }
.settings-row select,
.settings-row input { width: 130px; height: 38px; padding: 0 10px; font-size: 14px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); }

/* ── FAB (add game) ──────────────────────────── */
.fab {
  position: fixed; bottom: calc(20px + env(safe-area-inset-bottom));
  right: 20px; z-index: 20;
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--primary); color: #fff;
  font-size: 26px; border: none; cursor: pointer;
  box-shadow: 0 4px 14px rgba(79,70,229,.4);
  display: flex; align-items: center; justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
.fab:active { transform: scale(.94); }

/* ── Muted text ───────────────────────────────── */
.muted { font-size: 13px; color: var(--muted); }

/* ── Session ID display ───────────────────────── */
.session-id-box {
  background: var(--primary-l);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px; color: var(--primary);
  display: flex; align-items: center; justify-content: space-between;
}

/* ── Tabs (main screen) ───────────────────────── */
.tab-bar {
  display: flex; overflow-x: auto; gap: 4px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 12px;
  -ms-overflow-style: none; scrollbar-width: none;
}
.tab-bar::-webkit-scrollbar { display: none; }
.tab {
  flex-shrink: 0; height: 42px; padding: 0 14px;
  font-size: 14px; font-weight: 500; color: var(--muted);
  border: none; background: none; cursor: pointer;
  border-bottom: 2px solid transparent;
  -webkit-tap-highlight-color: transparent;
}
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ── Toast ───────────────────────────────────── */
.toast {
  position: fixed; bottom: calc(80px + env(safe-area-inset-bottom));
  left: 50%; transform: translateX(-50%);
  background: #1a1a1e; color: #fff;
  padding: 10px 18px; border-radius: 999px;
  font-size: 14px; z-index: 999;
  white-space: nowrap;
  animation: fadeInOut 2.8s ease forwards;
}
.toast-error   { background: var(--danger); }
.toast-success { background: var(--success); }
@keyframes fadeInOut {
  0%   { opacity: 0; transform: translateX(-50%) translateY(10px); }
  15%  { opacity: 1; transform: translateX(-50%) translateY(0); }
  75%  { opacity: 1; }
  100% { opacity: 0; }
}
