/* 駅名タイピング（/games/typing）
 * 設計: docs/station_typing_game_design_2026-09-25.md */

:root {
	--tg-bg: #eef2f5;
	--tg-surface: #ffffff;
	--tg-ink: #1d2733;
	--tg-muted: #6b7785;
	--tg-border: #d5dce3;
	--tg-accent: #1b7d3a;
	--tg-good: #1b7d3a;
	--tg-bad: #c62828;
	--tg-bonus: #b26a00;
	--tg-sky: #cfe3f3;
	--tg-platform: #9aa4ad;
}

* { box-sizing: border-box; }

body.tg-body {
	margin: 0;
	background: var(--tg-bg);
	color: var(--tg-ink);
	font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", Meiryo, sans-serif;
	-webkit-text-size-adjust: 100%;
}

.tg-header, .tg-footer {
	max-width: 960px;
	margin: 0 auto;
	padding: 10px 16px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	font-size: 14px;
}
.tg-header a, .tg-footer a { color: var(--tg-muted); text-decoration: none; }
.tg-header { gap: 12px; }
.tg-header .tg-logo { display: block; flex: 0 1 auto; min-width: 0; line-height: 0; }
.tg-header .tg-logo img { display: block; width: 200px; max-width: 100%; height: auto; }
.tg-account { display: inline-flex; align-items: center; gap: 6px; flex: 0 0 auto; font-size: 13px; color: var(--tg-muted); white-space: nowrap; }
.tg-account.is-member { color: var(--tg-ink); }
.tg-account-icon { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; }
.tg-account-name { font-weight: 700; max-width: 9em; overflow: hidden; text-overflow: ellipsis; }
.tg-account.is-member .tg-account-state { font-size: 11px; color: #fff; background: var(--tg-accent); border-radius: 999px; padding: 1px 8px; }
.tg-header a.tg-account-link { color: var(--tg-accent); font-weight: 700; border: 1px solid var(--tg-accent); border-radius: 999px; padding: 2px 12px; }
.tg-footer { color: var(--tg-muted); font-size: 12px; flex-wrap: wrap; gap: 8px; }

.tg {
	--tg-line: #1b7d3a;
	max-width: 960px;
	margin: 0 auto;
	padding: 0 16px 24px;
}

.tg-panel {
	background: var(--tg-surface);
	border: 1px solid var(--tg-border);
	border-radius: 12px;
	padding: 20px;
}

.tg-title {
	margin: 0 0 4px;
	font-size: 28px;
	font-weight: 900;
	letter-spacing: 0.04em;
}
.tg-title-sub { margin-left: 6px; font-size: 15px; font-weight: 700; letter-spacing: 0; color: var(--tg-muted); }
.tg-lead { margin: 0 0 20px; color: var(--tg-muted); font-size: 14px; }
.tg-shared { margin: -8px 0 20px; padding: 10px 14px; border-radius: 8px; background: #fff6e0; border: 1px solid #f0d58a; font-size: 14px; font-weight: 700; }

.tg-loading { padding: 60px 16px; text-align: center; color: var(--tg-muted); }

/* ---- 開始画面 ---- */
.tg-field { margin: 0 0 18px; }
.tg-field-label { display: block; font-weight: 700; margin-bottom: 8px; font-size: 14px; }

.tg-courses { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tg-ticket { position: relative; display: block; cursor: pointer; }
.tg-ticket input { position: absolute; opacity: 0; pointer-events: none; }
.tg-ticket-body {
	display: block;
	border: 2px solid var(--tg-border);
	border-radius: 8px;
	padding: 12px 10px;
	text-align: center;
	background: repeating-linear-gradient(135deg, #fbf7ea 0 8px, #f6f0dc 8px 16px);
	transition: border-color .15s, transform .15s;
}
.tg-ticket-kind { display: block; font-size: 20px; font-weight: 900; }
.tg-ticket-price { display: block; font-size: 15px; font-weight: 700; margin-top: 2px; }
.tg-ticket-time { display: block; font-size: 12px; color: var(--tg-muted); margin-top: 2px; }
.tg-ticket input:checked + .tg-ticket-body { border-color: var(--tg-accent); transform: translateY(-2px); box-shadow: 0 4px 0 var(--tg-accent); }
.tg-ticket input:focus-visible + .tg-ticket-body { outline: 3px solid #7fb2e5; }
.tg-ticket-note { font-size: 12px; color: var(--tg-muted); margin: 8px 0 0; }

.tg-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.tg-select, .tg-text {
	font-size: 16px; /* iOS のズーム防止 */
	padding: 8px 10px;
	border: 1px solid var(--tg-border);
	border-radius: 6px;
	background: #fff;
	color: var(--tg-ink);
	max-width: 100%;
}
.tg-text { min-width: 0; flex: 1 1 220px; }
.tg-info { font-size: 13px; color: var(--tg-muted); margin-top: 6px; }

.tg-segment { display: inline-flex; border: 1px solid var(--tg-border); border-radius: 8px; overflow: hidden; }
.tg-segment label { cursor: pointer; }
.tg-segment input { position: absolute; opacity: 0; pointer-events: none; }
.tg-segment span { display: block; padding: 8px 14px; font-size: 14px; background: #fff; }
.tg-segment input:checked + span { background: var(--tg-accent); color: #fff; font-weight: 700; }

.tg-start-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-top: 8px; }
.tg-btn {
	appearance: none;
	border: 0;
	border-radius: 999px;
	padding: 14px 32px;
	font-size: 18px;
	font-weight: 800;
	cursor: pointer;
	background: var(--tg-accent);
	color: #fff;
	box-shadow: 0 4px 0 #125a29;
}
.tg-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 #125a29; }
.tg-btn:disabled { background: #a9b3bb; box-shadow: none; cursor: not-allowed; }
.tg-btn-sub { background: #fff; color: var(--tg-ink); border: 1px solid var(--tg-border); box-shadow: none; font-size: 15px; padding: 10px 20px; }
.tg-btn-x { background: #111; box-shadow: 0 4px 0 #000; font-size: 15px; padding: 10px 20px; }
.tg-hint { font-size: 12px; color: var(--tg-muted); }
.tg-best { font-size: 13px; color: var(--tg-bonus); font-weight: 700; margin-top: 10px; min-height: 1em; }

/* ---- プレイ画面 ---- */
.tg-hud { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.tg-hud-item { font-size: 12px; color: var(--tg-muted); }
.tg-hud-item b { display: block; font-size: 22px; color: var(--tg-ink); font-variant-numeric: tabular-nums; }
.tg-hud-time b { font-size: 30px; }
.tg-bar { height: 6px; border-radius: 3px; background: var(--tg-border); overflow: hidden; }
.tg-bar > i { display: block; height: 100%; width: 100%; background: var(--tg-accent); }

.tg-scene {
	position: relative;
	height: 150px;
	margin: 10px 0 0;
	border-radius: 12px 12px 0 0;
	overflow: hidden;
	background: linear-gradient(var(--tg-sky), #e8f1f8 70%);
}
.tg-scene::after { /* ホーム */
	content: "";
	position: absolute;
	left: 0; right: 0; bottom: 0;
	height: 26px;
	background: repeating-linear-gradient(90deg, var(--tg-platform) 0 38px, #8c969f 38px 40px);
	border-top: 4px solid #f2c300; /* 点字ブロック */
}
.tg-train {
	position: absolute;
	left: 50%;
	bottom: 30px;
	width: 520px;
	height: 92px;
	margin-left: -260px;
	border-radius: 18px 18px 6px 6px;
	background: #e9edf0;
	border: 2px solid #b8c1c9;
	transform: translateX(130%);
}
.tg-train::before { /* 窓 */
	content: "";
	position: absolute;
	left: 18px; right: 18px; top: 14px;
	height: 30px;
	background: repeating-linear-gradient(90deg, #5b7185 0 58px, transparent 58px 72px);
	border-radius: 4px;
}
.tg-train::after { /* 路線色の帯 */
	content: "";
	position: absolute;
	left: 0; right: 0; top: 54px;
	height: 12px;
	background: var(--tg-line);
}
.tg-train.is-arriving { animation: tg-arrive .6s cubic-bezier(.2,.8,.3,1) forwards; }
.tg-train.is-departing { animation: tg-depart .5s ease-in forwards; }
@keyframes tg-arrive { from { transform: translateX(130%); } to { transform: translateX(0); } }
@keyframes tg-depart { from { transform: translateX(0); } to { transform: translateX(-140%); } }

.tg-stage-area { position: relative; }
.tg-countdown {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 64px;
	font-weight: 900;
	color: var(--tg-ink);
	background: rgba(255, 255, 255, .7);
	z-index: 3;
}

/* 駅名標 */
.tg-sign {
	position: relative;
	background: #fff;
	border: 1px solid var(--tg-border);
	border-top: 0;
	border-radius: 0 0 12px 12px;
	padding: 16px 16px 0;
	text-align: center;
	overflow: hidden;
}
.tg-sign-name { font-size: 44px; font-weight: 900; line-height: 1.2; letter-spacing: .06em; word-break: break-all; }
.tg-sign-kana { font-size: 22px; font-weight: 700; margin-top: 2px; letter-spacing: .1em; }
.tg-sign-kana .is-done { color: #b7c0c8; }
.tg-sign-sub { font-size: 13px; color: var(--tg-muted); margin-top: 4px; min-height: 1.2em; }
.tg-romaji {
	margin-top: 12px;
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: 26px;
	letter-spacing: .04em;
	word-break: break-all;
}
.tg-romaji .is-done { color: #b7c0c8; }
.tg-romaji .is-rest { color: var(--tg-ink); font-weight: 700; }
.tg-sign-band { height: 14px; margin: 14px -16px 0; background: var(--tg-line); }
.tg-depart { height: 6px; margin: 0 -16px; background: #e3e8ec; }
.tg-depart > i { display: block; height: 100%; width: 100%; background: #f2a900; transition: background .2s; }
.tg-sign.is-hurry .tg-depart > i { background: var(--tg-bad); }
.tg-sign.is-miss { animation: tg-shake .18s; }
@keyframes tg-shake { 0%, 100% { transform: none; } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

.tg-message { min-height: 1.6em; margin: 8px 0 0; text-align: center; font-weight: 800; font-size: 16px; }
.tg-message.is-good { color: var(--tg-good); }
.tg-message.is-bad { color: var(--tg-bad); }
.tg-message.is-bonus { color: var(--tg-bonus); }

.tg-kana-row { display: none; margin-top: 10px; }
.tg-kana-input {
	width: 100%;
	font-size: 22px;
	padding: 10px 12px;
	border: 2px solid var(--tg-border);
	border-radius: 8px;
	text-align: center;
}
.tg-kana-input.is-miss { border-color: var(--tg-bad); }
.tg[data-mode="kana"] .tg-kana-row { display: block; }
.tg[data-mode="kana"] .tg-romaji { display: none; }
.tg-play-hint { font-size: 12px; color: var(--tg-muted); text-align: center; margin-top: 8px; }
/* かな入力のときだけ出す（確定で発車。docs/typing_game_prepublish_issues_2026-09-25.md 12章） */
.tg-kana-hint { display: none; font-weight: 700; color: var(--tg-bonus); }
.tg[data-mode="kana"] .tg-kana-hint { display: block; }

/* ---- 結果画面 ---- */
.tg-verdict { text-align: center; padding: 8px 0 16px; }
.tg-verdict-amount { font-size: 40px; font-weight: 900; }
.tg-verdict-amount small { font-size: 16px; margin-left: 4px; }
.tg-verdict-line { font-size: 24px; font-weight: 900; margin-top: 4px; }
.tg-verdict-line.is-good { color: var(--tg-good); }
.tg-verdict-line.is-bad { color: var(--tg-bad); }
.tg-verdict-ticket { font-size: 13px; color: var(--tg-muted); margin-top: 6px; }
.tg-result-title { text-align: center; font-size: 20px; font-weight: 800; margin: 0 0 12px; }
.tg-result-best { text-align: center; color: var(--tg-bonus); font-weight: 700; min-height: 1.2em; margin-bottom: 12px; }
.tg-stats { width: 100%; max-width: 420px; margin: 0 auto 16px; border-collapse: collapse; font-size: 15px; }
.tg-stats th, .tg-stats td { padding: 6px 8px; border-bottom: 1px solid var(--tg-border); }
.tg-stats th { text-align: left; font-weight: 400; color: var(--tg-muted); }
.tg-stats td { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.tg-stations-head { font-size: 14px; font-weight: 700; margin: 0 0 8px; }
.tg-stations { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; }
.tg-chip {
	display: inline-block;
	padding: 4px 10px;
	border-radius: 999px;
	background: #eef5f0;
	border: 1px solid #cfe3d6;
	font-size: 13px;
	color: var(--tg-ink);
	text-decoration: none;
}
a.tg-chip { color: var(--tg-accent); }
a.tg-chip:hover { text-decoration: underline; }
.tg-chip.is-missed { background: #f6f7f8; border-color: var(--tg-border); color: #9aa4ad; text-decoration: line-through; }
.tg-result-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }

[hidden] { display: none !important; }

/* ---- スマホ ---- */
@media (max-width: 600px) {
	.tg-title { font-size: 22px; }
	.tg-title-sub { display: block; margin: 2px 0 0; font-size: 13px; }
	.tg-panel { padding: 14px; }
	.tg-courses { gap: 6px; }
	.tg-ticket-kind { font-size: 17px; }
	.tg-ticket-price { font-size: 13px; }
	.tg-scene { height: 90px; }
	.tg-scene::after { height: 16px; }
	.tg-train { width: 340px; margin-left: -170px; height: 58px; bottom: 20px; }
	.tg-train::before { top: 9px; height: 18px; background: repeating-linear-gradient(90deg, #5b7185 0 38px, transparent 38px 48px); }
	.tg-train::after { top: 34px; height: 8px; }
	.tg-sign { padding-top: 10px; }
	.tg-sign-name { font-size: 32px; }
	.tg-sign-kana { font-size: 18px; }
	.tg-romaji { font-size: 20px; }
	.tg-countdown { font-size: 44px; }
	.tg-verdict-amount { font-size: 32px; }
	.tg-verdict-line { font-size: 20px; }
	/* かなモードはソフトキーボードで下半分が隠れる前提で、上に詰める */
	.tg[data-mode="kana"][data-screen="play"] .tg-scene { display: none; }
	.tg[data-mode="kana"][data-screen="play"] .tg-sign { border-top: 1px solid var(--tg-border); border-radius: 12px; }
	.tg-header { padding: 8px 16px; }
	.tg-header .tg-logo img { width: 150px; }
	.tg-account .tg-account-state { display: none; }
	.tg-account.is-member .tg-account-state { display: inline; }
}

@media (prefers-reduced-motion: reduce) {
	.tg-train.is-arriving, .tg-train.is-departing, .tg-sign.is-miss { animation-duration: .01s; }
}

/* ---- 会員だけのランキング（docs/typing_ranking_member_design_2026-09-27.md） ---- */
.tg-rank { margin-top: 20px; border-top: 1px solid var(--tg-border); padding-top: 14px; }
.tg-rank-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.tg-rank-title { font-weight: 800; font-size: 15px; }
.tg-rank-tabs { display: inline-flex; border: 1px solid var(--tg-border); border-radius: 999px; overflow: hidden; }
.tg-rank-tab { border: 0; background: transparent; color: var(--tg-muted); font: inherit; font-size: 13px; padding: 4px 14px; cursor: pointer; }
.tg-rank-tab.is-active { background: var(--tg-accent); color: #fff; font-weight: 700; }
.tg-rank-list { list-style: none; margin: 0; padding: 0; }
.tg-rank-row { display: grid; grid-template-columns: 2em 24px minmax(0, 1fr) auto auto; align-items: center; gap: 8px; padding: 6px 2px; border-bottom: 1px dashed var(--tg-border); font-size: 14px; }
.tg-rank-no { font-weight: 800; text-align: right; color: var(--tg-muted); }
.tg-rank-row:nth-child(-n+3) .tg-rank-no { color: var(--tg-bonus); }
.tg-rank-icon { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; background: var(--tg-bg); }
.tg-rank-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tg-rank-earned { font-weight: 800; font-variant-numeric: tabular-nums; }
.tg-rank-kps { color: var(--tg-muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.tg-rank-empty { color: var(--tg-muted); font-size: 13px; padding: 8px 2px; }
.tg-rank-note { margin: 8px 0 0; color: var(--tg-muted); font-size: 12px; }
.tg-rank-note a { color: var(--tg-accent); font-weight: 700; }
.tg-result-rank { margin: 8px 0 12px; padding: 10px 12px; border-radius: 8px; background: var(--tg-bg); font-weight: 700; text-align: center; }
.tg-result-cta { margin: 8px 0 14px; padding: 12px; border: 2px dashed var(--tg-accent); border-radius: 10px; text-align: center; }
.tg-cta-text { margin: 0 0 10px; font-weight: 700; font-size: 14px; }
.tg-cta-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.tg-cta-actions .tg-btn { text-decoration: none; display: inline-block; }
@media (max-width: 480px) {
	.tg-rank-row { grid-template-columns: 1.6em 24px minmax(0, 1fr) auto; }
	.tg-rank-kps { display: none; }
}
