:root {
  --bg: #1f1a14;
  --panel: #2c251c;
  --panel-2: #3a3126;
  --line: #5a4a34;
  --text: #f1e7d0;
  --muted: #b9a888;
  --gold: #d8b25a;
  --danger: #ff7a6b;
  font-family: 'Yu Gothic UI', 'Yu Gothic', 'Hiragino Sans', sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
[hidden] { display: none !important; }
a { color: var(--gold); }
button, .button {
  font: inherit; color: var(--text); background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 6px; padding: 6px 14px; cursor: pointer; text-decoration: none; display: inline-block;
}
button:hover, .button:hover { border-color: var(--gold); }
button.primary, .button.primary { background: #8a2a1e; border-color: #c0503a; }
button.primary:hover, .button.primary:hover { background: #a3331f; }
button.ghost { background: transparent; }
button.small, .button.small { padding: 3px 10px; font-size: 13px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--danger); min-height: 1.2em; margin: 6px 0 0; font-size: 13px; }
input { font: inherit; padding: 7px 9px; border-radius: 6px; border: 1px solid var(--line); background: #1a1611; color: var(--text); }
input.upper { text-transform: uppercase; }
label { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; font-size: 14px; }
h2, h3 { margin: 0 0 12px; font-weight: 600; }
h3 { font-size: 16px; }

.topbar { height: 46px; display: flex; justify-content: space-between; align-items: center; padding: 0 18px; background: #15110c; border-bottom: 1px solid var(--line); }
.brand { font-family: Georgia, serif; letter-spacing: 3px; color: var(--gold); font-weight: 700; font-size: 18px; }
.brand span { font-family: 'Yu Mincho', serif; letter-spacing: 1px; font-size: 13px; color: var(--muted); margin-left: 8px; }
.topbar-right { display: flex; gap: 10px; align-items: center; font-size: 14px; }

.screen { max-width: 1240px; margin: 0 auto; padding: 28px 20px; }
.lead { color: var(--muted); margin: 0 0 18px; text-align: center; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 18px 20px; }
.login-choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.big-id { font-family: Consolas, monospace; font-size: 30px; letter-spacing: 6px; color: #ffe39a; text-align: center; margin: 10px 0 16px; }

.lobby { display: grid; grid-template-columns: 1fr 380px; gap: 22px; align-items: start; }
.gameGroups { display: flex; flex-direction: column; gap: 24px; }
.genre > .genreLabel { border-top: 1px solid var(--line); padding-top: 10px; margin-bottom: 12px;
  font-size: 15px; font-weight: 600; letter-spacing: 2px; color: var(--muted); }
.games { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.game { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; }
.game .art { height: 120px; display: flex; align-items: center; justify-content: center; font-family: 'Yu Mincho', serif; font-size: 28px; font-weight: 700; letter-spacing: 4px; color: #fff4d6; text-shadow: 0 2px 4px rgba(0,0,0,.6); }
.game .art.summoner { background: linear-gradient(135deg, #3b2a6e, #7a3fa0); }
.game .art.battleline { background: linear-gradient(135deg, #7d1f16, #c0392b 55%, #d8b25a); }
.game .art.wordchain { background: linear-gradient(135deg, #0f1b3d, #23407a 55%, #6fa8dc); }
.game .art.korokoro { background: linear-gradient(135deg, #5a3a1a, #a8431f 55%, #e2b86b); }
.game .art.aiueo { background: linear-gradient(135deg, #7a2e0b, #e8590c 55%, #ffc078); }
.game .art.ciaociao { background: linear-gradient(135deg, #16357e, #2f8a34 55%, #8fd14f); }
.game .art.citychase { background: linear-gradient(135deg, #151b3a, #2348d8 55%, #e32b22); }
.game .art.hiragajan { background: linear-gradient(135deg, #0e6d73, #1fa5a8 50%, #78c641 85%, #fdfcf7); }
.game .art.gobblet { background: linear-gradient(135deg, #1a6fa8, #2fa3e6 45%, #f2681f 55%, #b2420c); }
.game .body { padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.game .name { font-size: 18px; font-weight: 600; }
.game .desc { color: var(--muted); font-size: 13px; line-height: 1.5; flex: 1; }
.game .foot { display: flex; justify-content: space-between; align-items: center; }

.side { display: flex; flex-direction: column; gap: 14px; }
.rows { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.rows li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.rows li:last-child { border-bottom: none; }
.rows .empty { color: var(--muted); font-size: 13px; }
.rows .info { min-width: 0; }
.rows .title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rows .sub { color: var(--muted); font-size: 12px; }
.rows .actions { display: flex; gap: 6px; flex-shrink: 0; }
.rows.compact li { padding: 5px 0; }

/* ユーザー設定 */
.settings { display: flex; flex-direction: column; gap: 18px; max-width: 720px; }
.settings-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.settings-head h2 { margin: 0; flex: 1; }
.settings .panel hr { border: none; border-top: 1px solid var(--line); margin: 16px 0; }
.settings .inline-form { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.settings .inline-form label { margin-bottom: 0; }
.msg { min-height: 1.2em; margin: 8px 0 0; font-size: 13px; }
.msg.ok { color: #8fd39a; }
.msg.ng { color: var(--danger); }
.msg .mono, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .04em; }
.issued { background: #241d14; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-top: 10px; font-size: 13px; }
.issued b { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 15px; }
.badge { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 4px; margin-right: 6px; background: var(--panel-2); border: 1px solid var(--line); color: var(--gold); }
.badge.summoner { color: #d7b8ff; border-color: #6a4a9e; }
.badge.battleline { color: #ffb4a8; border-color: #9e4a3a; }
.badge.wordchain { color: #a8d0ff; border-color: #3a5e9e; }
.badge.korokoro { color: #ffd59a; border-color: #9e6a3a; }
.badge.aiueo { color: #ffc9a0; border-color: #b3541e; }
.badge.ciaociao { color: #c8ec3c; border-color: #2f8a34; }
.badge.citychase { color: #9fb4ff; border-color: #2348d8; }
.badge.hiragajan { color: #b6f08c; border-color: #1fa5a8; }
.badge.gobblet { color: #ffb27a; border-color: #2fa3e6; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #5cd65c; margin-right: 6px; }

/* ══════════ 画面が狭いとき ══════════ */
/* タブレット〜横向き: 右のサイドを下へ回す(380px固定のままだと横に収まらない) */
@media (max-width: 900px) {
  .lobby { grid-template-columns: 1fr; gap: 18px; }
  .side { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
}
@media (max-width: 760px) {
  .login-choices { grid-template-columns: 1fr; }
}
/* スマホ */
@media (max-width: 560px) {
  .screen { padding: 18px 14px; }
  .topbar { height: auto; min-height: 46px; padding: 7px 12px; gap: 8px; flex-wrap: wrap; }
  .brand { font-size: 15px; letter-spacing: 2px; }
  .brand span { display: none; }           /* 「ゲームロビー」の副題は幅を食うので省く */
  .topbar-right { font-size: 13px; gap: 7px; flex-wrap: wrap; justify-content: flex-end; }
  .topbar-right button { padding: 5px 10px; }
  .side { grid-template-columns: 1fr; }
  .panel { padding: 14px 15px; }
  .games { grid-template-columns: 1fr; gap: 12px; }
  .game .art { height: 92px; font-size: 22px; letter-spacing: 2px; }
  .game .body { padding: 12px 14px; gap: 6px; }
  .lead { text-align: left; }
  .big-id { font-size: 26px; letter-spacing: 4px; }
  /* iOS は16px未満の入力欄に触れると画面を勝手に拡大するので、スマホでは16pxにする */
  input { font-size: 16px; width: 100%; }
  label { font-size: 13px; }
  button, .button { padding: 8px 14px; }   /* 指で押せる大きさを確保 */
  button.small, .button.small { padding: 5px 10px; }
  /* 名前と操作ボタンが1行に収まらないので、折り返して縦に積む */
  .rows li { flex-wrap: wrap; }
  .rows .info { flex: 1 1 100%; }
  .rows .actions { flex: 1 1 100%; justify-content: flex-end; flex-wrap: wrap; }
  .rows.compact .info, .rows.compact .actions { flex: 0 1 auto; }
  .settings .inline-form { display: block; }
  .settings .inline-form label { margin-bottom: 10px; }
  .settings-head h2 { font-size: 20px; flex: 1 1 100%; }
}
