:root {
  --ink: #101315;
  --paper: #f3f1ea;
  --acid: #d7ff28;
  --blue: #446bff;
  --line: rgba(16, 19, 21, .18);
  --muted: #707578;
  --mono: "DM Mono", monospace;
  --sans: "Noto Sans JP", sans-serif;
  --header-height: 90px;
  --footer-height: 60px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--sans);
}
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
.noise {
  position: fixed; inset: 0; pointer-events: none; z-index: 99; opacity: .035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.7'/%3E%3C/svg%3E");
}
.topbar {
  height: var(--header-height); padding: 0 4vw; display: grid; grid-template-columns: minmax(250px, 1fr) auto minmax(0, .3fr);
  align-items: center; border-bottom: 1px solid var(--line); position: relative; z-index: 5;
}
.brand { display: flex; gap: 11px; align-items: center; color: inherit; text-decoration: none; }
.brand > span { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.brand b { font: 800 15px/1.1 var(--sans); letter-spacing: .03em; }
.brand small { color: var(--muted); font: 500 8px/1.25 var(--sans); white-space: nowrap; }
.brand-mark { width: 48px; height: 48px; display: block; object-fit: cover; object-position: center top; border: 1px solid var(--line); background: white; }
nav { height: 100%; display: flex; gap: 18px; }
.nav-button { border: 0; background: none; padding: 0 8px; font: 500 12px var(--mono); letter-spacing: .12em; position: relative; cursor: pointer; }
.nav-button span { color: var(--muted); font-size: 9px; margin-right: 7px; }
.nav-button.active::after { content: ""; position: absolute; height: 4px; background: var(--acid); left: 0; right: 0; bottom: 0; }
.session-stat { justify-self: end; display: flex; align-items: baseline; gap: 12px; }
.session-stat span { font: 500 9px var(--mono); color: var(--muted); letter-spacing: .15em; }
.session-stat strong { font: 500 22px var(--mono); }
main { min-height: calc(100vh - var(--header-height) - var(--footer-height)); }
.view { display: none; }
.view.active { display: block; }
.game-panel { padding: 25px 4vw 52px; max-width: 1600px; margin: 0 auto; }
.hidden { display: none !important; }
.eyebrow { display: flex; align-items: center; gap: 14px; font: 500 10px var(--mono); letter-spacing: .15em; color: var(--muted); }
.eyebrow i { width: 50px; height: 1px; background: var(--line); }
.game-filter-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.game-filter-tags span { padding: 6px 9px; color: var(--ink); background: var(--acid); }
.game-filter-tags .review-chip { background: var(--ink); color: white; }
.game-filter-tags .genre-chip { border: 1px solid var(--line); background: transparent; }
.game-heading { display: flex; justify-content: flex-start; gap: clamp(30px, 4vw, 68px); align-items: end; margin: 14px 0 20px; }
.game-heading > div:first-child { flex: 0 1 auto; min-width: 0; }
.game-heading .meta { flex: 0 0 auto; }
.kicker, .section-label { margin: 0 0 9px; font: 500 10px var(--mono); color: var(--blue); letter-spacing: .16em; }
.source-url { overflow-wrap: anywhere; text-transform: none; letter-spacing: .04em; }
h1 { margin: 0; max-width: 900px; font-size: clamp(34px, 4vw, 62px); font-weight: 900; letter-spacing: -.055em; line-height: .98; }
.meta { display: flex; gap: 38px; padding-bottom: 5px; }
.meta div { max-width: 180px; }
.meta span, .result-numbers span { display: block; margin-bottom: 6px; font: 500 9px var(--mono); color: var(--muted); letter-spacing: .13em; }
.meta strong { font-size: 12px; font-weight: 600; }
.media-grid { height: clamp(260px, 23vw, 340px); display: grid; grid-template-columns: auto minmax(250px, .72fr) minmax(360px, 1fr); gap: 7px; }
.trailer-frame { width: auto; height: 100%; aspect-ratio: 16 / 9; margin: 0; position: relative; overflow: hidden; background: #16191c; }
.trailer-frame video { display: block; width: 100%; height: 100%; object-fit: contain; }
.media-label { position: absolute; left: 14px; top: 14px; z-index: 2; padding: 7px 10px; color: white; background: rgba(16,19,21,.85); font: 500 9px var(--mono); letter-spacing: .12em; pointer-events: none; }
.screenshots { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.screenshot { position: relative; overflow: hidden; padding: 0; border: 0; background: #d9d8d1; cursor: zoom-in; }
.screenshot img { width: 100%; height: 100%; display: block; object-fit: cover; transition: transform .4s ease; }
.screenshot:hover img { transform: scale(1.04); }
.screenshot span { position: absolute; right: 8px; bottom: 7px; color: white; font: 500 9px var(--mono); text-shadow: 0 1px 5px #000; }
.briefing-grid { display: block; padding-top: 18px; }
.description-block { max-width: 1200px; }
.description-block > p:last-child { margin: 8px 0 0; font-size: 13px; line-height: 1.75; }
.guess-block { height: 100%; display: flex; flex-direction: column; justify-content: center; border-left: 1px solid var(--line); padding: 10px 0 10px 2.5vw; }
.guess-block label { display: block; margin: 7px 0 7px; font-weight: 700; font-size: 14px; }
.number-input { display: flex; align-items: end; border-bottom: 2px solid var(--ink); }
.number-input input { width: 100%; min-width: 0; padding: 2px 0 6px; border: 0; outline: none; background: transparent; font: 500 clamp(28px, 3vw, 43px) var(--mono); letter-spacing: -.06em; }
.number-input input::placeholder { color: #c2c1bc; }
.number-input span { padding-bottom: 10px; font: 500 9px var(--mono); color: var(--muted); letter-spacing: .1em; }
.slider-wrap { margin: 12px 0 0; }
#guessSlider { width: 100%; height: 18px; margin: 0; appearance: none; background: transparent; cursor: pointer; }
#guessSlider:disabled { cursor: not-allowed; opacity: .55; }
#guessSlider::-webkit-slider-runnable-track { height: 4px; background: linear-gradient(90deg, var(--acid) var(--slider-fill, 57%), #cfcec7 var(--slider-fill, 57%)); }
#guessSlider::-moz-range-track { height: 4px; background: #cfcec7; }
#guessSlider::-moz-range-progress { height: 4px; background: var(--acid); }
#guessSlider::-webkit-slider-thumb { width: 17px; height: 17px; margin-top: -6.5px; appearance: none; border: 3px solid var(--paper); border-radius: 50%; background: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
#guessSlider::-moz-range-thumb { width: 12px; height: 12px; border: 3px solid var(--paper); border-radius: 50%; background: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.scale-labels { display: flex; justify-content: space-between; margin-top: 1px; font: 500 8px var(--mono); color: var(--muted); }
.quick-picks { display: flex; gap: 6px; margin-top: 12px; }
.quick-picks button { flex: 1; padding: 7px; border: 1px solid var(--line); background: transparent; font: 500 10px var(--mono); cursor: pointer; }
.quick-picks button:hover { background: var(--ink); color: white; }
#guessHint { min-height: 15px; margin: 4px 0 8px; color: var(--muted); font-size: 10px; }
#guessHint.error { color: #d82e43; }
.primary-button { min-height: 50px; border: 0; padding: 0 22px; color: var(--ink); background: var(--acid); font-weight: 800; cursor: pointer; box-shadow: inset 0 0 0 1px rgba(0,0,0,.16); transition: transform .15s, background .15s; }
.primary-button:hover { background: #e4ff6b; transform: translateY(-2px); }
.guess-block .primary-button { width: 100%; display: flex; justify-content: space-between; align-items: center; }
.loading-state, .error-state { min-height: calc(100vh - 136px); display: grid; place-content: center; justify-items: center; text-align: center; }
.loading-state p { margin: 25px 0 5px; font: 500 12px var(--mono); letter-spacing: .16em; }
.loading-state small { color: var(--muted); }
.scanner { width: 210px; height: 4px; background: #d7d5cd; overflow: hidden; }
.scanner span { display: block; width: 35%; height: 100%; background: var(--blue); animation: scan 1.1s infinite ease-in-out; }
@keyframes scan { 0% { transform: translateX(-100%); } 100% { transform: translateX(400%); } }
.error-state p { max-width: 420px; }
.result-panel { position: fixed; inset: auto 0 0; z-index: 20; padding: 22px 4vw; display: grid; grid-template-columns: minmax(315px, .8fr) minmax(300px, 1fr) minmax(327px, auto); gap: clamp(16px, 2vw, 35px); align-items: center; color: white; background: var(--ink); box-shadow: 0 -15px 45px rgba(0,0,0,.25); animation: reveal .32s ease-out; }
@keyframes reveal { from { transform: translateY(100%); } }
.result-copy > p { margin: 0 0 15px; font-weight: 700; }
.result-numbers { display: flex; gap: 0; }
.result-numbers > div { min-width: 105px; padding: 0 18px; border-left: 1px solid #3f4446; }
.result-numbers > div:first-child { padding-left: 0; border-left: 0; }
.result-numbers span { color: #8c9295; }
.result-numbers strong { font: 500 21px var(--mono); }
#actualResult { color: var(--acid); }
.sentiment-line { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 17px; }
.sentiment-line span { color: var(--acid); font-weight: 800; }
.sentiment-line strong { font: 500 12px var(--mono); color: #c6cbcd; }
.reveal-scale { position: relative; height: 54px; }
.reveal-track { position: absolute; top: 18px; left: 0; right: 0; height: 3px; background: #555a5d; }
.reveal-track i { position: absolute; left: var(--line-left, 0%); width: var(--line-width, 0%); height: 100%; background: var(--acid); transform-origin: left; animation: stretchLine .8s .25s both cubic-bezier(.2,.75,.25,1); }
.scale-marker { position: absolute; top: 11px; left: 0; z-index: 2; transform: translateX(-50%); }
.scale-marker span { display: block; width: 16px; height: 16px; border: 3px solid var(--ink); border-radius: 50%; background: white; box-shadow: 0 0 0 1px white; }
.scale-marker b { position: absolute; bottom: 22px; left: 50%; transform: translateX(-50%); white-space: nowrap; font: 500 8px var(--mono); color: #9da2a5; }
.guess-marker { left: var(--guess-pos, 50%); }
.actual-marker { left: var(--actual-pos, 50%); animation: moveActual 1s .15s both cubic-bezier(.2,.75,.25,1); }
.actual-marker span { background: var(--acid); box-shadow: 0 0 0 1px var(--acid), 0 0 18px rgba(215,255,40,.4); }
.actual-marker b { color: var(--acid); }
.reveal-labels { position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between; font: 500 7px var(--mono); color: #707679; }
.scale-labels span:only-child, .reveal-labels span:only-child { margin: 0 auto; }
@keyframes moveActual { from { left: var(--guess-pos, 50%); } to { left: var(--actual-pos, 50%); } }
@keyframes stretchLine { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.result-actions { display: flex; flex-direction: row; gap: 10px; min-width: 327px; align-items: stretch; justify-content: flex-end; }
.result-actions a { color: #b8bdc0; text-align: center; font: 500 10px var(--mono); letter-spacing: .08em; }
.result-secondary-actions { flex: 0 0 132px; height: 50px; display: flex; flex-direction: column; gap: 3px; }
.result-actions .steam-page-button { flex: 1 1 auto; min-height: 31px; display: flex; align-items: center; justify-content: center; padding: 5px 9px; border: 1px solid white; color: var(--ink); background: white; text-decoration: none; white-space: nowrap; font: 700 9px var(--sans); }
.result-actions .steam-page-button:hover { color: var(--ink); background: var(--acid); border-color: var(--acid); }
.share-result-button { flex: 0 0 16px; min-height: 0; display: flex; align-items: center; justify-content: flex-start; padding: 0; border: 0; color: #c8cdcf; background: transparent; text-decoration: underline; text-underline-offset: 3px; white-space: nowrap; font: 500 12px var(--mono); cursor: pointer; }
.share-result-button:hover { color: var(--acid); }
.result-actions #nextButton { flex: 0 0 185px; min-height: 50px; }
.page-view { max-width: 1500px; margin: 0 auto; padding: 65px 4vw 100px; }
.page-heading { display: flex; justify-content: space-between; align-items: end; margin-bottom: 50px; }
.page-heading h1 { font-size: clamp(45px, 6vw, 85px); }
.text-button { border: 0; border-bottom: 1px solid; background: transparent; color: var(--muted); font-size: 12px; cursor: pointer; }
.page-heading-actions { display: flex; align-items: center; gap: 18px; }
.share-history-button { padding: 11px 18px; border: 1px solid var(--ink); background: var(--acid); font-weight: 700; font-size: 13px; cursor: pointer; }
.share-history-button:hover { background: var(--ink); color: var(--acid); }
.stats-grid { margin-bottom: 35px; }
.stat-card { display: flex; align-items: baseline; gap: 10px; }
.stat-card span { font: 500 9px var(--mono); color: var(--muted); letter-spacing: .13em; }
.stat-card strong { font: 500 16px var(--mono); }
.table-wrap { position: relative; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 820px; }
th { padding: 13px 10px; border-bottom: 1px solid var(--ink); text-align: left; color: var(--muted); font: 500 9px var(--mono); letter-spacing: .1em; }
td { padding: 18px 10px; border-bottom: 1px solid var(--line); font: 400 12px var(--mono); }
td:nth-child(2) { font: 700 13px var(--sans); }
.history-steam-link { display: inline-block; color: var(--ink); font: 700 10px var(--mono); text-underline-offset: 4px; }
.empty-history { padding: 60px; text-align: center; color: var(--muted); font-size: 13px; border-bottom: 1px solid var(--line); }
.settings-card { display: grid; grid-template-columns: .8fr 1.2fr; gap: 7vw; padding: 45px; border: 1px solid var(--line); background: rgba(255,255,255,.24); }
.settings-card h2 { margin: 12px 0 10px; font-size: 28px; }
.settings-card p:last-child { color: var(--muted); line-height: 1.8; font-size: 13px; }
.setting-group { min-width: 0; }
.setting-group + .setting-group { padding-top: 18px; border-top: 1px solid var(--line); }
.segmented { display: grid; gap: 10px; }
.segmented.compact { grid-template-columns: 1fr 1fr; margin-top: 12px; }
.segmented label { cursor: pointer; }
.segmented input { position: absolute; opacity: 0; }
.segmented label > span { display: flex; flex-direction: column; gap: 5px; padding: 22px; border: 1px solid var(--line); position: relative; }
.segmented label > span::after { content: ""; position: absolute; right: 22px; top: 25px; width: 12px; height: 12px; border: 1px solid var(--ink); border-radius: 50%; }
.segmented input:checked + span { color: white; border-color: var(--ink); background: var(--ink); }
.segmented input:checked + span::after { border: 4px solid var(--acid); width: 6px; height: 6px; }
.segmented small { color: var(--muted); font-size: 11px; }
.segmented input:checked + span small { color: #a9aeb1; }
.range-inputs { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: end; margin-top: 12px; }
.range-inputs > i { padding-bottom: 13px; color: var(--muted); font-style: normal; }
.range-inputs label { min-width: 0; }
.range-inputs label > span { display: block; margin-bottom: 4px; color: var(--muted); font: 500 9px var(--mono); letter-spacing: .1em; }
.range-inputs select { width: 100%; height: 42px; padding: 0 34px 0 10px; border: 1px solid var(--ink); outline: 0; background-color: var(--paper); font: 500 16px var(--mono); cursor: pointer; }
.range-inputs select:focus { box-shadow: inset 0 -3px var(--acid); }
.range-inputs select option:disabled { color: #a6aaa9; }
.range-inputs small { display: block; margin-top: 3px; color: var(--muted); font-size: 9px; text-align: right; }
.tag-settings-card { margin-top: 16px; padding: 36px 45px 42px; border: 1px solid var(--line); background: rgba(255,255,255,.24); }
.tag-settings-heading { display: flex; justify-content: space-between; align-items: end; gap: 30px; }
.tag-settings-heading h2 { margin: 10px 0 7px; font-size: 28px; }
.tag-settings-heading p:last-child { margin: 0; color: var(--muted); font-size: 12px; }
.selected-tags { min-height: 42px; display: flex; flex-wrap: wrap; gap: 7px; margin: 25px 0 15px; padding-bottom: 15px; border-bottom: 1px solid var(--line); }
.selected-tags:empty::before { content: "未選択 — すべてのタグから出題"; align-self: center; color: var(--muted); font-size: 11px; }
.selected-tag { display: inline-flex; align-items: center; gap: 9px; padding: 8px 11px; border: 0; background: var(--ink); color: white; font-size: 11px; cursor: pointer; }
.selected-tag i { color: var(--acid); font: normal 15px/1 var(--mono); }
.tag-search { height: 48px; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 11px; padding: 0 15px; border: 1px solid var(--ink); background: var(--paper); }
.tag-search > span { font: 500 23px var(--mono); transform: rotate(-15deg); }
.tag-search input { width: 100%; border: 0; outline: 0; background: transparent; font-size: 13px; }
.tag-search small { color: var(--muted); font: 500 9px var(--mono); }
.tag-list { max-height: 270px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; margin-top: 10px; overflow-y: auto; background: var(--line); border: 1px solid var(--line); }
.tag-option { min-height: 39px; display: flex; align-items: center; gap: 9px; padding: 8px 11px; border: 0; background: var(--paper); text-align: left; font-size: 11px; cursor: pointer; }
.tag-option::before { content: "+"; flex: 0 0 auto; color: var(--muted); font: 500 14px var(--mono); }
.tag-option:hover { background: white; }
.tag-option.selected { background: var(--acid); color: var(--ink); font-weight: 700; }
.tag-option.selected::before { content: "✓"; color: var(--ink); }
.tag-error { margin: 12px 0 0; color: #d82e43; font-size: 11px; }
.setup-card { margin-top: 0; }
.setup-major-tags { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.setup-major-tag { padding: 15px 26px; border: 1px solid var(--ink); background: var(--paper); font-size: 17px; font-weight: 700; cursor: pointer; transition: box-shadow .12s, transform .12s; }
.setup-major-tag:hover { background: white; }
.setup-major-tag.selected { background: var(--acid); box-shadow: 4px 4px 0 var(--ink); transform: translate(-2px, -2px); }
.setup-count { font: 500 9px var(--mono); color: var(--muted); letter-spacing: .13em; white-space: nowrap; }
.setup-actions { margin-top: 24px; }
.setup-actions .primary-button { min-width: 280px; min-height: 56px; font-size: 16px; }
.lightbox { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 4vh 5vw; background: rgba(8, 10, 12, .92); backdrop-filter: blur(8px); animation: lightboxFade .2s ease-out; }
.lightbox-content { max-width: 100%; max-height: 100%; margin: 0; display: flex; flex-direction: column; align-items: center; gap: 10px; animation: lightboxZoom .25s ease-out; }
.lightbox-content img { display: block; max-width: 90vw; max-height: 84vh; width: auto; height: auto; object-fit: contain; box-shadow: 0 24px 70px rgba(0,0,0,.5); }
.lightbox-content figcaption { color: #b8bdc0; font: 500 10px var(--mono); letter-spacing: .08em; }
.lightbox-close { position: fixed; top: 22px; right: 27px; z-index: 2; width: 48px; height: 48px; display: grid; place-items: center; padding: 0; border: 1px solid rgba(255,255,255,.35); border-radius: 50%; color: white; background: rgba(16,19,21,.65); font: 300 30px/1 var(--sans); cursor: pointer; transition: color .15s, border-color .15s, transform .15s; }
.lightbox-close:hover { color: var(--acid); border-color: var(--acid); transform: rotate(8deg); }
.lightbox-nav { position: fixed; top: 50%; z-index: 2; width: 54px; height: 70px; display: grid; place-items: center; padding: 0; border: 1px solid rgba(255,255,255,.35); color: white; background: rgba(16,19,21,.68); font: 300 46px/1 var(--sans); cursor: pointer; transform: translateY(-50%); transition: color .15s, border-color .15s, background .15s; }
.lightbox-nav:hover { color: var(--acid); border-color: var(--acid); background: rgba(16,19,21,.9); }
.lightbox-previous { left: 24px; }
.lightbox-next { right: 24px; }
.share-dialog { position: fixed; inset: 0; z-index: 110; display: grid; place-items: center; padding: 24px; background: rgba(8,10,12,.78); backdrop-filter: blur(8px); animation: lightboxFade .2s ease-out; }
.share-dialog-card { position: relative; width: min(590px, 100%); padding: 34px; border: 1px solid var(--ink); background: var(--paper); box-shadow: 0 24px 70px rgba(0,0,0,.38); animation: lightboxZoom .25s ease-out; }
.share-dialog-card h2 { margin: 8px 0 20px; font-size: 30px; }
.share-dialog-close { position: absolute; top: 16px; right: 16px; width: 38px; height: 38px; display: grid; place-items: center; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: transparent; font-size: 24px; cursor: pointer; }
.share-dialog-close:hover { border-color: var(--ink); transform: rotate(8deg); }
.share-dialog textarea { width: 100%; min-height: 125px; padding: 16px; resize: vertical; border: 1px solid var(--ink); outline: 0; color: var(--ink); background: white; font: 500 15px/1.8 var(--sans); }
.share-dialog textarea:focus { box-shadow: inset 0 -3px var(--acid); }
.share-dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 12px; }
.share-dialog-actions a,
.share-dialog-actions button { min-height: 48px; display: flex; align-items: center; justify-content: center; padding: 10px 14px; border: 1px solid var(--ink); color: white; background: var(--ink); text-decoration: none; font-weight: 800; cursor: pointer; }
.share-dialog-actions a { color: var(--ink); background: var(--acid); }
.copy-status { min-height: 20px; margin: 8px 0 0; color: var(--blue); font-size: 12px; }
@keyframes lightboxFade { from { opacity: 0; } }
@keyframes lightboxZoom { from { opacity: 0; transform: scale(.96); } }
footer { min-height: var(--footer-height); padding: 10px 4vw; display: flex; gap: 24px; justify-content: space-between; align-items: center; border-top: 1px solid var(--line); color: var(--muted); font: 500 8px/1.55 var(--mono); letter-spacing: .07em; }
footer a { color: var(--ink); font-size: 11px; font-weight: 700; text-underline-offset: 3px; }
body[data-view="creator"] .game-filter-tags .scope-chip { background: var(--blue); color: white; }

@media (min-width: 641px) {
  body[data-view="game"], body[data-view="creator"] { height: 100dvh; overflow: hidden; }
  body[data-view="game"] main, body[data-view="creator"] main { height: calc(100dvh - var(--header-height) - var(--footer-height)); min-height: 0; }
  body[data-view="game"] #gameView, body[data-view="creator"] #gameView { height: 100%; }
  body[data-view="game"] .game-panel, body[data-view="creator"] .game-panel { height: 100%; padding-top: 16px; padding-bottom: 16px; overflow: hidden; }
  body[data-view="game"] .media-grid, body[data-view="creator"] .media-grid { height: clamp(170px, calc(100dvh - 440px), 340px); }
  body[data-view="game"] .description-block > p:last-child,
  body[data-view="creator"] .description-block > p:last-child { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
  body[data-view="game"] .result-panel, body[data-view="creator"] .result-panel { bottom: var(--footer-height); max-height: calc(100dvh - var(--header-height) - var(--footer-height)); overflow-y: auto; z-index: 40; }

  body[data-view="settings"] { height: 100dvh; overflow: hidden; }
  body[data-view="settings"] main { height: calc(100dvh - var(--header-height) - var(--footer-height)); min-height: 0; }
  body[data-view="settings"] #settingsView.active {
    width: 100%; height: 100%; max-width: none; padding: 15px 4vw;
    display: grid; grid-template-columns: minmax(330px, .72fr) minmax(0, 1.28fr);
    grid-template-rows: auto minmax(0, 1fr); gap: 11px 14px;
  }
  body[data-view="settings"] .page-heading { grid-column: 1 / -1; margin: 0; align-items: center; }
  body[data-view="settings"] .page-heading h1 { font-size: clamp(36px, 4.5vh, 48px); line-height: 1; }
  body[data-view="settings"] .page-heading .kicker { margin-bottom: 5px; }
  body[data-view="settings"] .settings-card {
    grid-column: 1; grid-row: 2; min-height: 0; padding: 26px;
    grid-template-columns: 1fr; align-content: start; gap: 14px; overflow-y: auto;
  }
  body[data-view="settings"] .settings-card h2,
  body[data-view="settings"] .tag-settings-heading h2 { margin-top: 7px; font-size: 23px; }
  body[data-view="settings"] .settings-card p:last-child { margin-bottom: 0; }
  body[data-view="settings"] .segmented { gap: 7px; }
  body[data-view="settings"] .segmented label > span { padding: 12px 14px; }
  body[data-view="settings"] .segmented label > span::after { top: 15px; right: 14px; }
  body[data-view="settings"] .setting-group + .setting-group { padding-top: 12px; }
  body[data-view="settings"] .tag-settings-card {
    grid-column: 2; grid-row: 2; min-height: 0; height: 100%; margin: 0; padding: 24px 28px;
    display: flex; flex-direction: column;
  }
  body[data-view="settings"] .tag-settings-heading { flex: 0 0 auto; }
  body[data-view="settings"] .selected-tags { flex: 0 0 auto; min-height: 36px; margin: 14px 0 9px; padding-bottom: 9px; }
  body[data-view="settings"] .selected-tag { padding: 6px 9px; }
  body[data-view="settings"] .tag-search { flex: 0 0 42px; height: 42px; }
  body[data-view="settings"] .tag-list { flex: 1 1 auto; min-height: 100px; max-height: none; grid-template-columns: repeat(4, minmax(0, 1fr)); }
  body[data-view="settings"] .tag-option { min-height: 35px; }

  body[data-view="setup"] { height: 100dvh; overflow: hidden; }
  body[data-view="setup"] main { height: calc(100dvh - var(--header-height) - var(--footer-height)); min-height: 0; }
  body[data-view="setup"] #setupView.active { height: 100%; max-width: none; padding: 14px 4vw; display: flex; flex-direction: column; gap: 12px; min-height: 0; }
  body[data-view="setup"] .page-heading { margin: 0; }
  body[data-view="setup"] .page-heading h1 { font-size: clamp(30px, 4.5vh, 50px); line-height: 1.1; }
  body[data-view="setup"] .page-heading .kicker { margin-bottom: 5px; }
  body[data-view="setup"] .setup-card { flex: 0 1 auto; min-height: 0; padding: 16px 28px 20px; overflow-y: auto; }
  body[data-view="setup"] .setup-major-tags { gap: 8px; margin-top: 12px; }
  body[data-view="setup"] .setup-major-tag { padding: 10px 18px; font-size: 15px; }
  body[data-view="setup"] .setup-actions { margin-top: 0; }
}

@media (min-width: 641px) and (max-width: 1060px) {
  .result-panel { grid-template-columns: minmax(315px, .8fr) minmax(300px, 1fr); }
  .result-actions { grid-column: 1 / -1; min-width: 0; }
}

@media (min-width: 641px) and (max-height: 760px) {
  :root { --header-height: 76px; }
  .game-heading { margin-top: 7px; margin-bottom: 12px; }
  h1 { font-size: clamp(30px, min(3.5vw, 6.2vh), 52px); }
  .media-grid { min-height: 0; }
  .briefing-grid { padding-top: 15px; }
  .description-block > p:last-child { margin-top: 5px; font-size: 12px; line-height: 1.6; }
  .guess-block label { margin-top: 4px; }
  .number-input input { font-size: clamp(26px, 2.7vw, 38px); }
  .slider-wrap { margin-top: 7px; }
  .primary-button { min-height: 43px; }
}

@media (min-width: 641px) and (max-width: 900px) {
  .topbar { grid-template-columns: minmax(180px, 1fr) auto; padding: 0 2vw; }
  .brand small { display: none; }
  nav { gap: 3px; }
  .nav-button { padding: 0 4px; font-size: 10px; letter-spacing: .04em; }
  .nav-button span { margin-right: 3px; }
  body[data-view="game"] .game-panel,
  body[data-view="creator"] .game-panel { padding-left: 2vw; padding-right: 2vw; }
  .game-heading { gap: 20px; margin-top: 8px; margin-bottom: 12px; }
  h1 { font-size: clamp(28px, 5vw, 42px); }
  .meta { gap: 16px; }
  .media-grid { grid-template-columns: minmax(210px, 1.1fr) minmax(145px, .72fr) minmax(225px, 1fr); }
  .trailer-frame { width: 100%; aspect-ratio: auto; }
  .guess-block { padding-left: 16px; }
  body[data-view="settings"] #settingsView.active { grid-template-columns: minmax(260px, .8fr) minmax(0, 1.2fr); padding-left: 2vw; padding-right: 2vw; }
  body[data-view="settings"] .settings-card { padding: 18px; }
  body[data-view="settings"] .tag-settings-card { padding: 18px; }
  body[data-view="settings"] .tag-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  footer { padding-left: 2vw; padding-right: 2vw; gap: 10px; font-size: 7px; }
}

/* 横向きスマートフォンなど、高さが極端に低い端末ではページスクロールを許可する。 */
@media (min-width: 641px) and (max-width: 900px) and (max-height: 500px) {
  body[data-view="game"], body[data-view="creator"], body[data-view="settings"] { height: auto; overflow: auto; }
  body[data-view="game"] main, body[data-view="creator"] main, body[data-view="settings"] main { height: auto; min-height: calc(100vh - var(--header-height) - var(--footer-height)); }
  body[data-view="game"] #gameView, body[data-view="creator"] #gameView,
  body[data-view="game"] .game-panel, body[data-view="creator"] .game-panel { height: auto; overflow: visible; }
  body[data-view="game"] .media-grid, body[data-view="creator"] .media-grid { height: 220px; }
  body[data-view="settings"] #settingsView.active { height: auto; min-height: calc(100vh - var(--header-height) - var(--footer-height)); }
  body[data-view="settings"] .settings-card,
  body[data-view="settings"] .tag-settings-card { height: auto; overflow: visible; }
  body[data-view="settings"] .tag-list { max-height: 270px; }
}

@media (max-width: 640px) {
  :root { --header-height: 72px; }
  .topbar { display: flex; gap: 7px; height: 72px; padding: 0 8px; }
  .brand { flex: 0 0 auto; gap: 6px; }
  .brand-mark { width: 32px; height: 32px; }
  .brand b { font-size: 10px; white-space: nowrap; }
  nav { position: static; z-index: auto; flex: 1 1 auto; width: auto; min-width: 0; height: 100%; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 2px; background: transparent; border: 0; }
  .nav-button { min-width: 0; padding: 0 1px; font-size: clamp(7px, 2vw, 8px); line-height: 1.15; letter-spacing: 0; white-space: nowrap; }
  .nav-button span { display: block; margin: 0 0 3px; font-size: 6px; }
  .brand small { display: none; }
  .nav-button.active::after { top: auto; bottom: 0; }
  .session-stat { display: none; }
  main { min-height: calc(100vh - var(--header-height) - var(--footer-height)); padding-bottom: 0; }
  .briefing-grid, .settings-card { grid-template-columns: 1fr; }
  .game-heading { width: 100%; display: flex; flex-direction: column; align-items: stretch; gap: 13px; }
  .game-heading > div:first-child { order: 2; width: 100%; flex: 0 0 auto; }
  .game-heading h1 { width: 100%; max-width: none; }
  .game-heading .meta { order: 1; width: 100%; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; padding-bottom: 0; }
  .game-heading .meta div { max-width: none; min-width: 0; }
  .game-heading .meta strong { display: block; overflow-wrap: anywhere; }
  .media-grid { height: auto; grid-template-columns: 1fr; }
  .trailer-frame { width: 100%; height: auto; aspect-ratio: 16 / 9; }
  .screenshots { height: 360px; }
  .guess-block { border-left: 0; border-top: 1px solid var(--line); padding: 35px 0 0; }
  .result-panel { padding: 20px; grid-template-columns: 1fr; }
  .distance-result { grid-column: 1 / -1; }
  .result-actions { grid-column: 1 / -1; min-width: 0; flex-direction: row; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
  .result-actions #nextButton { flex: 1 0 185px; }
  .tag-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .segmented.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .segmented label > span { min-height: 70px; justify-content: center; padding: 12px 10px; }
  .segmented label > span::after { top: 14px; right: 10px; }
  .segmented b { padding-right: 17px; font-size: 13px; line-height: 1.35; }
  .segmented small { font-size: 9px; line-height: 1.45; }

  .table-wrap { overflow: visible; }
  .table-wrap table { min-width: 0; display: block; }
  .table-wrap thead { display: none; }
  .table-wrap tbody { display: grid; gap: 10px; }
  .table-wrap tbody tr { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; padding: 12px 14px; border: 1px solid var(--line); background: rgba(255,255,255,.24); }
  .table-wrap tbody td { min-width: 0; padding: 3px 0; border: 0; font-size: 10px; }
  .table-wrap tbody td:nth-child(1) { grid-column: 1; grid-row: 1; padding-right: 9px; color: var(--muted); }
  .table-wrap tbody td:nth-child(2) { grid-column: 2 / 4; grid-row: 1; overflow-wrap: anywhere; font-size: 14px; }
  .table-wrap tbody td:nth-child(3) { grid-column: 1 / 3; grid-row: 2; }
  .table-wrap tbody td:nth-child(4) { grid-column: 3; grid-row: 2; text-align: right; }
  .table-wrap tbody td:nth-child(5) { grid-column: 1 / 3; grid-row: 3; color: var(--muted); }
  .table-wrap tbody td:nth-child(6) { grid-column: 3; grid-row: 3; text-align: right; }
  .table-wrap tbody td:nth-child(3)::before { content: "正解 "; color: var(--muted); font-size: 8px; letter-spacing: .08em; }
  .table-wrap tbody td:nth-child(4)::before { content: "集計 "; color: var(--muted); font-size: 8px; letter-spacing: .08em; }
  .table-wrap tbody td:nth-child(5)::before { content: "日時 "; font-size: 8px; letter-spacing: .08em; }
  .history-steam-link { font-size: 10px; }
  footer { min-height: auto; margin-bottom: 0; flex-direction: column; align-items: flex-start; gap: 8px; }
}

@media (max-width: 540px) {
  .game-panel, .page-view { padding-left: 20px; padding-right: 20px; }
  .game-panel { padding-top: 32px; }
  .game-heading { gap: 18px; }
  .meta { gap: 20px; }
  .screenshots { height: 260px; }
  .briefing-grid { padding-top: 35px; }
  .result-copy > p { font-size: 13px; }
  .result-numbers { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .result-panel { max-height: 68vh; overflow-y: auto; }
  .settings-card { padding: 18px; }
  .tag-settings-card { padding: 18px; }
  .tag-settings-heading { align-items: start; }
  .tag-search { grid-template-columns: auto 1fr; }
  .tag-search small { display: none; }
  .page-heading { margin-bottom: 35px; }
  #setupView .page-heading { margin-bottom: 22px; }
  #setupView h1 { font-size: clamp(30px, 8.5vw, 45px); }
  .setup-major-tags { gap: 8px; margin-top: 16px; }
  .setup-major-tag { flex: 1 0 calc(50% - 8px); padding: 13px 10px; font-size: 15px; text-align: center; }
  .setup-actions .primary-button { width: 100%; }
  .share-dialog-card { padding: 28px 20px 20px; }
  .share-dialog-actions { grid-template-columns: 1fr; }
  .lightbox { padding-left: 54px; padding-right: 54px; }
  .lightbox-nav { width: 42px; height: 58px; font-size: 38px; }
  .lightbox-previous { left: 6px; }
  .lightbox-next { right: 6px; }
}

@media (max-width: 360px) {
  .topbar { gap: 5px; padding-left: 6px; padding-right: 6px; }
  .brand-mark { width: 27px; height: 27px; }
  .brand { gap: 4px; }
  .brand b { font-size: 9px; }
  .nav-button { padding-left: 1px; padding-right: 1px; font-size: 6.5px; }
}
