:root {
  color-scheme: light;
  --app-height: 100dvh;
  --mobile-browser-bottom-gap: 0px;
  --touch-controls-bottom: 18px;
  --ink: #1d1b1b;
  --panel: rgba(255, 255, 255, 0.86);
  --accent: #db342f;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
  overflow-x: hidden;
  width: 100%;
}

html.portal-page,
html.portal-page body {
  height: auto;
  min-height: 100%;
  overflow-y: visible;
  touch-action: auto;
}

body {
  align-items: center;
  background: #fff;
  color: var(--ink);
  display: flex;
  font-family:
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Hiragino Sans",
    "Noto Sans JP",
    sans-serif;
  justify-content: center;
  padding: 18px;
  overscroll-behavior: none;
}

html.is-touch,
html.is-touch body,
html.is-touch button,
html.is-touch canvas {
  touch-action: none;
  user-select: none;
  -webkit-user-drag: none;
  -webkit-user-select: none;
}

html.portal-page.is-touch,
html.portal-page.is-touch body,
html.portal-page.is-touch button {
  touch-action: auto;
}

button {
  border: 0;
  cursor: pointer;
  font: inherit;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.portal-body {
  align-items: stretch;
  background: #fff;
  display: block;
  min-height: 100vh;
  overscroll-behavior: auto;
  padding: 28px;
  touch-action: auto;
}

.portal-shell {
  display: grid;
  gap: 22px;
  margin: auto;
  max-width: 980px;
  min-width: 0;
  width: min(100%, 980px);
}

.portal-narrow {
  max-width: 760px;
}

.portal-hero {
  align-items: center;
  border-bottom: 4px solid rgba(29, 27, 27, 0.84);
  display: grid;
  gap: 20px;
  grid-template-columns: minmax(0, 1fr) 180px;
  min-height: 240px;
  overflow: hidden;
  padding: 18px 4px 26px;
}

.portal-date {
  color: #db342f;
  font-size: 17px;
  font-weight: 900;
  letter-spacing: 0;
  margin: 0 0 8px;
}

.portal-hero h1 {
  font-size: clamp(44px, 8vw, 86px);
  line-height: 1;
  margin: 0 0 12px;
}

.portal-hero p:not(.portal-date) {
  font-size: clamp(16px, 2.2vw, 22px);
  font-weight: 800;
  line-height: 1.55;
  margin: 0;
}

.portal-hero img {
  align-self: end;
  height: 190px;
  object-fit: contain;
  width: 180px;
}

.content-links {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.quick-links {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.content-card {
  background: rgba(255, 255, 255, 0.86);
  border: 3px solid rgba(29, 27, 27, 0.76);
  border-radius: 8px;
  color: var(--ink);
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1fr) 112px;
  grid-template-rows: 1fr;
  align-items: center;
  min-height: 164px;
  padding: 22px;
  text-decoration: none;
  transition:
    box-shadow 160ms ease,
    transform 160ms ease;
}

.quick-card {
  grid-template-columns: 1fr;
  justify-items: center;
  min-height: 132px;
  text-align: center;
}

.quick-card .content-thumb {
  grid-column: 1;
  grid-row: 1;
  width: 88px;
}

.quick-card .content-text {
  grid-column: 1;
  grid-row: 2;
}

.quick-card strong {
  font-size: clamp(20px, 3vw, 30px);
}

.score-card {
  grid-column: 2;
}

.content-kicker {
  color: #5d5955;
  display: block;
  font-size: 13px;
  font-weight: 900;
}

.content-card strong {
  display: block;
  font-size: clamp(26px, 4vw, 40px);
  line-height: 1.1;
}

.content-text {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.content-text span:last-child {
  font-size: 16px;
  font-weight: 800;
  line-height: 1.45;
}

.content-thumb {
  align-items: center;
  background: #f3f3f3;
  border: 2px solid rgba(29, 27, 27, 0.16);
  border-radius: 8px;
  display: flex;
  grid-column: 2;
  grid-row: 1;
  height: auto;
  aspect-ratio: 1 / 1;
  justify-content: center;
  overflow: hidden;
  width: 100%;
}

.content-thumb img {
  display: block;
  height: 100%;
  object-fit: cover;
  width: 100%;
}

.thumb-tournament {
  background: #1d1b1b;
  color: #fff;
  font-size: 72px;
  font-weight: 900;
}

.thumb-score {
  background: #db342f;
  color: #fff;
  font-size: 52px;
  font-weight: 900;
}

.content-card:hover,
.content-card:focus-visible,
.back-link:hover,
.back-link:focus-visible {
  box-shadow: 0 10px 20px rgba(29, 27, 27, 0.12);
  transform: translateY(-2px);
}

.back-link,
.message-menu-link {
  align-items: center;
  background: #fff;
  border: 2px solid rgba(29, 27, 27, 0.72);
  border-radius: 999px;
  color: var(--ink);
  display: inline-flex;
  font-size: 30px;
  font-weight: 900;
  height: 42px;
  justify-content: center;
  justify-self: center;
  line-height: 1;
  padding: 0;
  text-decoration: none;
  width: 42px;
}

.text-back-link {
  border-radius: 8px;
  font-size: 16px;
  height: auto;
  line-height: 1.2;
  margin-top: 14px;
  min-height: 42px;
  padding: 10px 18px;
  width: auto;
}

.tsume-shell {
  max-width: 1120px;
}

.tsume-top-link {
  justify-self: start;
}

.profile-shell {
  max-width: 820px;
}

.profile-panel,
.profile-card {
  background: rgba(255, 255, 255, 0.94);
  border: 2px solid rgba(29, 27, 27, 0.72);
  border-radius: 8px;
  display: grid;
  gap: 14px;
  padding: 20px;
}

.profile-card {
  position: relative;
}

.profile-panel p {
  font-weight: 800;
  margin: 0;
}

.profile-panel label {
  display: grid;
  font-size: 14px;
  font-weight: 900;
  gap: 6px;
}

.profile-panel select,
.profile-panel button,
.profile-card button {
  border: 2px solid rgba(29, 27, 27, 0.62);
  border-radius: 8px;
  color: var(--ink);
  font: inherit;
  font-weight: 900;
  padding: 10px 12px;
}

.profile-panel button,
.profile-card button {
  background: var(--ink);
  color: #fff;
}

.profile-card > #changeProfile {
  background: transparent;
  border: 0;
  color: #5d5955;
  font-size: 13px;
  padding: 0;
  position: absolute;
  right: 16px;
  top: 14px;
}

.profile-card > #changeProfile:hover,
.profile-card > #changeProfile:focus-visible {
  color: var(--ink);
  text-decoration: underline;
}

.profile-card .profile-team {
  color: #db342f;
  font-size: 15px;
  font-weight: 900;
  margin: 0;
}

.profile-card h2 {
  font-size: clamp(32px, 5vw, 54px);
  line-height: 1;
  margin: 0;
}

.profile-card dl {
  display: grid;
  gap: 8px 14px;
  grid-template-columns: max-content minmax(0, 1fr);
  margin: 0;
}

.profile-card dt {
  color: #5d5955;
  font-weight: 900;
}

.profile-card .profile-empty-label {
  display: none;
}

.profile-card dd {
  font-weight: 800;
  margin: 0;
}

.match-panel {
  border-top: 2px solid rgba(29, 27, 27, 0.12);
  display: grid;
  gap: 10px;
  margin-top: 4px;
  padding-top: 16px;
}

.match-panel h3 {
  font-size: 18px;
  margin: 0;
}

.match-help {
  color: #5d5955;
  font-size: 13px;
  font-weight: 800;
  margin: 0;
}

.match-search {
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) auto;
}

.match-search input {
  border: 2px solid rgba(29, 27, 27, 0.62);
  border-radius: 8px;
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  min-width: 0;
  padding: 10px 12px;
}

.opponent-results {
  display: grid;
  gap: 6px;
}

.opponent-results:empty {
  display: none;
}

.opponent-results button,
.match-list button {
  background: #fff;
  color: var(--ink);
}

.match-list {
  display: grid;
  gap: 6px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.match-list:empty::before {
  color: #5d5955;
  content: "対戦相手は未登録です。";
  font-size: 13px;
  font-weight: 800;
}

.match-list li {
  align-items: center;
  border: 2px solid rgba(29, 27, 27, 0.12);
  border-radius: 8px;
  display: flex;
  gap: 8px;
  justify-content: space-between;
  padding: 8px 10px;
}

.match-list button {
  font-size: 12px;
  padding: 4px 8px;
}

.score-sheet-panel {
  background: rgba(255, 255, 255, 0.94);
  border: 2px solid rgba(29, 27, 27, 0.72);
  border-radius: 8px;
  display: grid;
  gap: 14px;
  padding: 22px;
}

.score-sheet-panel h1 {
  font-size: clamp(34px, 7vw, 64px);
  line-height: 1;
  margin: 0;
}

.score-owner {
  color: #5d5955;
  font-weight: 900;
  margin: 0;
}

.score-total {
  align-items: baseline;
  display: flex;
  gap: 8px;
}

.score-total strong {
  color: #db342f;
  font-size: clamp(56px, 14vw, 110px);
  line-height: 0.9;
}

.score-total span {
  font-size: 24px;
  font-weight: 900;
}

.score-stamps {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(5, 1fr);
}

.score-stamps span {
  aspect-ratio: 1 / 1;
  border: 3px solid rgba(29, 27, 27, 0.3);
  border-radius: 999px;
  color: rgba(29, 27, 27, 0.36);
  display: grid;
  font-size: clamp(14px, 4vw, 24px);
  font-weight: 900;
  place-items: center;
  position: relative;
}

.score-stamps span.is-filled {
  background: #db342f;
  border-color: #db342f;
  color: #fff;
}

.score-stamps span.is-prize::before {
  background: url("./shizuoko_images/gkok001_01.png") center / contain no-repeat;
  content: "";
  inset: 12%;
  opacity: 0.28;
  position: absolute;
}

.score-stamps span.is-prize.is-filled::before {
  filter: brightness(0) invert(1);
  opacity: 0.42;
}

.score-breakdown {
  display: grid;
  gap: 8px 14px;
  grid-template-columns: minmax(0, 1fr) max-content;
  margin: 0;
}

.score-breakdown dt,
.score-breakdown dd {
  border-top: 1px solid rgba(29, 27, 27, 0.12);
  font-weight: 900;
  margin: 0;
  padding-top: 8px;
}

.score-breakdown dd {
  text-align: right;
}

.score-breakdown dd::after {
  color: #5d5955;
  content: attr(data-detail);
  display: block;
  font-size: 12px;
  margin-top: 2px;
}

.score-actions {
  display: grid;
  gap: 8px;
  justify-items: center;
}

.claim-prize {
  background: var(--ink);
  border: 2px solid rgba(29, 27, 27, 0.72);
  border-radius: 8px;
  color: #fff;
  font: inherit;
  font-weight: 900;
  padding: 12px 14px;
}

.claim-status {
  color: #db342f;
  font-size: 14px;
  font-weight: 900;
  margin: 0;
}

.tsume-hero {
  grid-template-columns: minmax(0, 1fr) 150px;
  min-height: 190px;
}

.tsume-hero img {
  height: 150px;
  width: 150px;
}

.puzzle-list {
  display: grid;
  gap: 12px;
}

.puzzle-panel {
  background: rgba(255, 255, 255, 0.94);
  border: 2px solid rgba(29, 27, 27, 0.72);
  border-radius: 8px;
  min-width: 0;
  overflow: hidden;
}

.puzzle-panel > summary {
  align-items: center;
  cursor: pointer;
  display: grid;
  gap: 8px 12px;
  grid-template-columns: minmax(0, 1fr) 76px;
  list-style: none;
  padding: 16px 18px;
}

.puzzle-panel > summary::-webkit-details-marker,
.card-group > summary::-webkit-details-marker {
  display: none;
}

.puzzle-panel > summary::after {
  content: "開く";
  font-size: 13px;
  font-weight: 900;
  grid-column: 1;
  grid-row: 2;
  justify-self: start;
  margin-left: 0;
}

.puzzle-panel[open] > summary {
  border-bottom: 2px solid rgba(29, 27, 27, 0.12);
}

.puzzle-panel[open] > summary::after {
  content: "閉じる";
}

.puzzle-thumb {
  aspect-ratio: 1 / 1;
  background: #f3f3f3;
  border: 2px solid rgba(29, 27, 27, 0.18);
  border-radius: 8px;
  display: block;
  grid-column: 2;
  grid-row: 1 / span 2;
  height: 76px;
  overflow: hidden;
  padding: 0;
  width: 76px;
}

.puzzle-thumb img {
  display: block;
  height: 100%;
  object-fit: cover;
  width: 100%;
}

.puzzle-title {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.puzzle-title > span {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.puzzle-title > span > b {
  background: #f3f3f3;
  border: 1px solid rgba(29, 27, 27, 0.2);
  border-radius: 999px;
  color: #db342f;
  font-size: 13px;
  font-weight: 900;
  padding: 3px 9px;
  white-space: nowrap;
}

.puzzle-clear-mark {
  color: #1f9d48;
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
}

.puzzle-title strong {
  font-size: clamp(18px, 2.4vw, 26px);
}

.puzzle-content {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(280px, 0.9fr) minmax(0, 1.1fr);
  min-width: 0;
  padding: 18px;
}

.puzzle-content.is-board-only {
  grid-template-columns: minmax(0, 1fr);
}

.puzzle-main {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.puzzle-rule {
  border: 2px solid rgba(29, 27, 27, 0.16);
  border-radius: 8px;
  color: var(--ink);
  display: grid;
  font-size: 14px;
  font-weight: 800;
  gap: 5px;
  line-height: 1.45;
  padding: 10px 12px;
}

.puzzle-rule p {
  margin: 0;
}

.puzzle-board {
  aspect-ratio: 1 / 1;
  background: #fff;
  border: 2px solid rgba(29, 27, 27, 0.28);
  border-radius: 8px;
  display: block;
  min-width: 0;
  overflow: hidden;
  padding: 8px;
  width: 100%;
}

.puzzle-board img {
  display: block;
  height: 100%;
  max-height: 720px;
  max-width: 100%;
  object-fit: contain;
  width: 100%;
}

.card-groups {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.standalone-card-groups {
  margin: 0 18px 18px;
}

.card-group {
  border: 2px solid rgba(29, 27, 27, 0.24);
  border-radius: 8px;
  min-width: 0;
  padding: 12px;
}

.card-group > summary {
  cursor: pointer;
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
  list-style: none;
  margin: 0;
}

.card-group > summary::after {
  content: "閉じる";
  color: #5d5955;
  float: right;
  font-size: 12px;
  font-weight: 900;
}

.card-group:not([open]) > summary::after {
  content: "開く";
}

.card-group[open] > .card-grid {
  margin-top: 10px;
}

.card-grid {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
}

.card-grid button {
  align-items: center;
  background: #fff;
  border: 0;
  border-radius: 0;
  color: var(--ink);
  display: block;
  flex: 0 0 auto;
  font-size: 14px;
  font-weight: 900;
  min-height: 0;
  padding: 0;
}

.card-grid button img {
  border-radius: 0;
  display: block;
  height: 124px;
  object-fit: contain;
  width: 90px;
}

.card-grid button span {
  display: none;
}

.puzzle-placeholder {
  color: #5d5955;
  font-weight: 800;
  margin: 0;
  padding: 0 18px 18px;
}

.puzzle-quiz {
  border-top: 2px solid rgba(29, 27, 27, 0.12);
  margin: 0 18px 18px;
  padding-top: 14px;
}

.puzzle-quiz form {
  display: grid;
  gap: 10px;
}

.puzzle-quiz form > strong {
  font-size: 17px;
}

.puzzle-quiz label {
  display: grid;
  gap: 6px;
  font-size: 14px;
  font-weight: 900;
}

.puzzle-quiz select,
.puzzle-quiz button {
  background: #fff;
  border: 2px solid rgba(29, 27, 27, 0.72);
  border-radius: 8px;
  color: var(--ink);
  font: inherit;
  font-weight: 900;
  padding: 9px 14px;
}

.puzzle-quiz button {
  background: #db342f;
  color: #fff;
}

.puzzle-quiz button:disabled {
  background: #5d5955;
}

.quiz-status {
  color: #5d5955;
  font-size: 13px;
  font-weight: 900;
  margin: 0;
}

.quiz-status.is-correct {
  color: #db342f;
}

.quiz-status.is-wrong {
  color: #1d1b1b;
}

.zoom-dialog {
  background: rgba(255, 255, 255, 0.98);
  border: 3px solid rgba(29, 27, 27, 0.82);
  border-radius: 8px;
  max-height: min(92vh, 900px);
  max-width: min(92vw, 980px);
  padding: 42px 14px 14px;
}

.zoom-dialog::backdrop {
  background: rgba(0, 0, 0, 0.62);
}

.zoom-dialog img {
  display: block;
  max-height: calc(92vh - 70px);
  max-width: calc(92vw - 36px);
  object-fit: contain;
}

.zoom-close {
  background: var(--ink);
  border-radius: 999px;
  color: #fff;
  font-size: 18px;
  font-weight: 900;
  height: 32px;
  position: absolute;
  right: 10px;
  top: 8px;
  width: 32px;
}

.game-shell {
  display: grid;
  gap: 12px;
  max-width: 960px;
  min-width: 0;
  width: min(100%, 960px);
}

.stage-wrap {
  aspect-ratio: 16 / 9;
  background: #8fd5ee;
  border: 3px solid rgba(29, 27, 27, 0.85);
  border-radius: 8px;
  box-shadow: 0 18px 36px rgba(22, 53, 45, 0.28);
  min-width: 0;
  overflow: hidden;
  position: relative;
  touch-action: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  width: 100%;
}

canvas {
  display: block;
  height: 100%;
  width: 100%;
}

.hud {
  display: flex;
  gap: 8px;
  left: 12px;
  pointer-events: none;
  position: absolute;
  top: 12px;
  z-index: 5;
}

.hud > div {
  align-items: baseline;
  background: var(--panel);
  border: 2px solid rgba(29, 27, 27, 0.78);
  border-radius: 8px;
  display: flex;
  gap: 6px;
  min-width: 92px;
  padding: 7px 10px;
}

.hud .oko-panel {
  min-width: 190px;
}

.hud .oko-panel.is-damage {
  animation: oko-shake 90ms linear infinite;
  background: rgba(255, 235, 235, 0.95);
  border-color: rgba(205, 24, 24, 0.92);
  box-shadow: 0 0 0 3px rgba(225, 26, 26, 0.18);
}

.hud-label {
  color: #4b4848;
  font-size: 12px;
  font-weight: 700;
}

.hud strong {
  font-size: 18px;
  line-height: 1;
}

.oko-meter {
  background: rgba(29, 27, 27, 0.18);
  border: 2px solid rgba(29, 27, 27, 0.72);
  border-radius: 999px;
  height: 13px;
  overflow: hidden;
  width: 86px;
}

.oko-meter span {
  background: #db342f;
  display: block;
  height: 100%;
  transition: width 120ms linear;
  width: 100%;
}

.oko-panel.is-damage .oko-meter {
  background: rgba(255, 0, 0, 0.16);
  border-color: rgba(205, 24, 24, 0.9);
}

.oko-panel.is-damage .oko-meter span {
  background: #d40000;
}

.oko-panel.is-damage strong {
  color: #c41616;
}

@keyframes oko-shake {
  0%,
  100% {
    transform: translateX(0);
  }

  25% {
    transform: translateX(-20px);
    transform: translateY(-20px);
  }

  75% {
    transform: translateX(20px);
    transform: translateY(20px);
  }
}

.message {
  align-items: center;
  background: rgba(250, 252, 246, 0.9);
  display: none;
  flex-direction: column;
  inset: 0;
  justify-content: center;
  padding: 20px;
  position: absolute;
  text-align: center;
  user-select: none;
  z-index: 10;
}

.message.is-visible {
  display: flex;
}

.message-menu-link {
  left: 16px;
  position: absolute;
  top: 16px;
}

.stage-wrap:has(.message.is-visible) .hud,
.stage-wrap:has(.message.is-visible) .touch-controls {
  display: none;
}

.message h1 {
  font-size: clamp(28px, 7vw, 60px);
  line-height: 1.05;
  margin: 36px 0 12px;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.message-image-wrap {
  display: none;
  height: min(34%, 190px);
  margin-bottom: 8px;
  position: relative;
  width: min(72%, 260px);
}

.message-image-wrap:has(img.is-visible) {
  display: block;
}

.message img {
  display: none;
  height: 100%;
  object-fit: contain;
  width: 100%;
}

.message img.is-visible {
  display: block;
}

.message-image-copy {
  display: none;
  left: 50%;
  position: absolute;
  top: 66%;
  transform: translateX(-50%);
  white-space: nowrap;
}

.message-image-grade,
.message-image-text {
  display: block;
  font-weight: 900;
  line-height: 1;
  text-align: left;
  white-space: nowrap;
}

.message-image-grade {
  color: #d81919;
  font-size: clamp(11px, 1.8vw, 15px);
  min-height: 1em;
}

.message-image-text {
  color: #2b2420;
  font-size: clamp(21px, 3.75vw, 29px);
  margin-top: clamp(6px, 1vw, 9px);
}

.message.is-win .message-image-copy {
  display: block;
}

.message.is-win h1 {
  display: none;
}

.message p {
  font-size: clamp(15px, 2.2vw, 20px);
  font-weight: 700;
  line-height: 1.5;
  margin: 0 0 16px;
  max-width: calc(100% - 28px);
  overflow-wrap: anywhere;
}

.message p.title-description {
  display: grid;
  font-size: 15px;
  line-height: 1.45;
  overflow-wrap: normal;
  white-space: nowrap;
}

.controls-guide {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 0 0 18px;
  max-width: min(680px, calc(100% - 32px));
  width: 100%;
}

.controls-guide div {
  background: rgba(255, 255, 255, 0.72);
  border: 2px solid rgba(29, 27, 27, 0.58);
  border-radius: 8px;
  padding: 8px 10px;
}

.controls-guide dt,
.controls-guide dd {
  margin: 0;
}

.controls-guide dt {
  color: #514d4d;
  font-size: 12px;
  font-weight: 800;
}

.controls-guide dd {
  font-size: 16px;
  font-weight: 900;
  line-height: 1.25;
}

.message button,
.touch-controls button {
  background: var(--ink);
  border-radius: 8px;
  color: white;
  font-weight: 900;
}

.message button {
  box-shadow: inset 0 -4px 0 rgba(255, 255, 255, 0.18);
  font-size: 20px;
  min-width: 160px;
  padding: 12px 22px;
  touch-action: manipulation;
}

.message .stage-return-button {
  background: #fff;
  border: 2px solid rgba(29, 27, 27, 0.62);
  box-shadow: none;
  color: var(--ink);
  font-size: 14px;
  margin-top: 9px;
  min-width: 0;
  padding: 8px 14px;
}

.stage-select {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 0 0 14px;
  max-width: min(560px, calc(100% - 28px));
  width: 100%;
}

.stage-select button {
  background: rgba(255, 255, 255, 0.78);
  border: 2px solid rgba(29, 27, 27, 0.62);
  border-radius: 8px;
  color: var(--ink);
  display: grid;
  font-size: 15px;
  font-weight: 900;
  gap: 3px;
  min-width: 0;
  padding: 9px 12px;
}

.stage-select button span:first-child {
  display: block;
  font-size: 15px;
}

.stage-select button span:last-child {
  display: block;
  font-size: 13px;
}

.stage-select button.is-selected {
  background: #db342f;
  border-color: rgba(29, 27, 27, 0.84);
  color: #fff;
}

.record-panel {
  background: rgba(255, 255, 255, 0.68);
  border: 2px solid rgba(29, 27, 27, 0.45);
  border-radius: 8px;
  display: grid;
  gap: 5px;
  margin: 0 0 14px;
  max-width: min(560px, calc(100% - 28px));
  padding: 8px 10px;
  width: 100%;
}

.record-panel div {
  display: flex;
  font-size: 13px;
  font-weight: 800;
  justify-content: space-between;
}

.record-panel strong {
  font-size: inherit;
}

.result-lines {
  display: grid;
  gap: 4px;
}

.result-line {
  align-items: baseline;
  display: grid;
  gap: 5px;
  grid-template-columns: 1em max-content max-content max-content;
  justify-content: center;
  line-height: 1.35;
}

.result-star {
  color: #f28c20;
}

.result-points {
  color: #4f4a45;
  font-size: 0.86em;
}

@media (min-width: 761px) and (hover: hover) and (pointer: fine) {
  .controls-guide {
    grid-template-columns: 1fr;
    margin: 0;
    max-width: 190px;
    position: absolute;
    right: 18px;
    top: 138px;
    width: 190px;
  }

  .controls-guide div {
    padding: 7px 9px;
  }

  .record-panel {
    margin: 0;
    max-width: 240px;
    padding-top: 28px;
    position: absolute;
    right: 18px;
    top: 18px;
    width: 240px;
  }

  .record-panel::before {
    color: #514d4d;
    content: "最高記録";
    font-size: 13px;
    font-weight: 900;
    left: 10px;
    position: absolute;
    top: 7px;
  }

  .record-panel div {
    font-size: 12px;
  }
}

.touch-controls {
  display: none;
  --touch-button-font-size: clamp(15px, 3vw, 20px);
}

.touch-controls button {
  border: 2px solid rgba(255, 255, 255, 0.24);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.2);
  position: absolute;
  touch-action: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
}

.touch-controls .jump {
  background: rgba(44, 143, 159, 0.72);
}

.touch-controls .attack {
  background: rgba(219, 52, 47, 0.72);
}

.rotate-hint {
  display: none;
}

html.is-touch {
  --mobile-browser-bottom-gap: 72px;
}

@media (max-width: 760px), (hover: none), (pointer: coarse), (max-height: 500px) {
  html.portal-page,
  html.portal-page body.portal-body {
    height: auto;
    min-height: 100%;
    overflow-y: visible;
    touch-action: auto;
  }

  html,
  body {
    height: var(--app-height);
    min-height: var(--app-height);
    overflow: hidden;
  }

  body {
    align-items: center;
    justify-content: center;
    padding: 0;
  }

  body.portal-body {
    align-items: stretch;
    height: auto;
    justify-content: flex-start;
    min-height: var(--app-height);
    overflow-y: auto;
    padding: 16px;
  }

  html.portal-page,
  html.portal-page body.portal-body {
    height: auto;
    min-height: 100%;
    overflow-y: visible;
    touch-action: auto;
  }

  .portal-shell {
    gap: 14px;
  }

  .portal-hero {
    gap: 12px;
    grid-template-columns: minmax(0, 1fr) 96px;
    min-height: 180px;
    padding: 18px;
  }

  .portal-hero img {
    height: 118px;
    width: 96px;
  }

  .tsume-hero {
    grid-template-columns: minmax(0, 1fr) 86px;
  }

  .tsume-hero img {
    height: 104px;
    width: 86px;
  }

  .content-links {
    grid-template-columns: 1fr;
  }

  .score-card {
    grid-column: auto;
  }

  .quick-links {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .content-card {
    grid-template-columns: minmax(0, 1fr) 92px;
    min-height: 132px;
    padding: 18px;
  }

  .content-card strong {
    font-size: clamp(24px, 6.8vw, 34px);
    white-space: nowrap;
  }

  .quick-card {
    grid-template-columns: 1fr;
    min-height: 118px;
    padding: 14px;
  }

  .quick-card strong {
    font-size: clamp(15px, 4vw, 20px);
    white-space: nowrap;
  }

  .quick-card .content-thumb {
    width: 72px;
  }

  .content-thumb {
    height: auto;
  }

  .thumb-tournament {
    font-size: 54px;
  }

  .profile-card dl {
    grid-template-columns: 1fr;
  }

  .puzzle-panel > summary {
    align-items: center;
    gap: 8px;
    grid-template-columns: minmax(0, 1fr) 72px;
    padding: 14px;
  }

  .puzzle-panel > summary::after {
    margin-left: 0;
  }

  .puzzle-thumb {
    height: 72px;
    width: 72px;
  }

  .puzzle-content {
    grid-template-columns: 1fr;
    min-width: 0;
    padding: 14px;
  }

  .puzzle-board {
    max-width: 100%;
    min-width: 0;
  }

  .puzzle-board img {
    height: 100%;
    max-height: none;
  }

  .message-menu-link {
    left: 10px;
    top: 10px;
  }

  .game-shell {
    display: block;
    height: var(--app-height);
    max-width: none;
    width: 100vw;
  }

  .stage-wrap {
    border-radius: 0;
    border-width: 0;
    box-shadow: none;
    height: min(var(--app-height), calc(100vw * 9 / 16));
    margin: 0 auto;
    width: min(100vw, calc(var(--app-height) * 16 / 9));
  }

  .hud {
    display: grid;
    gap: 6px;
    grid-template-columns: max-content max-content max-content;
    left: 8px;
    max-width: calc(100% - 16px);
    right: 8px;
    top: max(18px, calc(env(safe-area-inset-top) + 12px));
  }

  .hud > div {
    background: rgba(255, 255, 255, 0.9);
    min-width: 68px;
    padding: 5px 7px;
  }

  .hud .oko-panel {
    grid-column: 1 / -1;
    grid-row: 2;
    min-width: 150px;
    width: max-content;
  }

  .hud .time-panel {
    grid-column: 3;
    grid-row: 1;
  }

  .oko-meter {
    width: 58px;
  }

  .hud-label {
    font-size: 10px;
  }

  .hud strong {
    font-size: 14px;
  }

  .controls-guide {
    display: none;
  }

  .record-panel {
    position: static;
  }

  .message {
    padding: 12px;
  }

  .message h1 {
    font-size: clamp(26px, 8vh, 42px);
    margin-top: 38px;
    margin-bottom: 6px;
    text-wrap: balance;
  }

  .message p {
    font-size: clamp(13px, 3.2vh, 16px);
    line-height: 1.35;
    margin-bottom: 12px;
    max-width: 44em;
    text-wrap: balance;
  }

  .message button {
    font-size: 17px;
    padding: 8px 18px;
  }

  .touch-controls {
    bottom: max(var(--touch-controls-bottom), calc(env(safe-area-inset-bottom) + var(--touch-controls-bottom)));
    display: block;
    height: clamp(34px, 6.8vw, 46px);
    left: 0;
    pointer-events: none;
    position: fixed;
    right: 0;
    width: 100%;
    z-index: 20;
  }

  .touch-controls button {
    border-radius: 7px;
    align-items: center;
    display: flex;
    font-size: var(--touch-button-font-size);
    height: clamp(34px, 6.8vw, 46px);
    justify-content: center;
    line-height: 1;
    overflow-wrap: normal;
    pointer-events: auto;
    white-space: nowrap;
    word-break: keep-all;
    width: clamp(104px, 17vw, 136px);
  }

  .touch-controls .jump {
    bottom: 0;
    left: max(14px, env(safe-area-inset-left));
  }

  .touch-controls .attack {
    bottom: 0;
    right: max(14px, env(safe-area-inset-right));
    font-size: var(--touch-button-font-size);
    width: clamp(128px, 20vw, 164px);
  }
}

@media (max-width: 760px) and (orientation: landscape),
  (hover: none) and (orientation: landscape),
  (pointer: coarse) and (orientation: landscape),
  (max-height: 500px) and (orientation: landscape) {
  .stage-wrap {
    aspect-ratio: auto;
    height: calc(var(--app-height) - var(--mobile-browser-bottom-gap));
    min-height: calc(var(--app-height) - var(--mobile-browser-bottom-gap));
    width: 100vw;
  }

  .hud {
    top: max(20px, calc(env(safe-area-inset-top) + 14px));
  }

  .rotate-hint {
    display: none;
  }
}

@media (max-width: 760px) and (orientation: portrait),
  (hover: none) and (orientation: portrait),
  (pointer: coarse) and (orientation: portrait) {
  body {
    align-items: start;
  }

  .game-shell {
    display: flex;
    flex-direction: column;
    gap: 10px;
    height: var(--app-height);
    padding-top: max(126px, calc(env(safe-area-inset-top) + 114px));
    position: relative;
  }

  .game-shell::after {
    background: url("./shizuoko_images/gkok009_01.png") center / contain no-repeat;
    bottom: max(86px, calc(env(safe-area-inset-bottom) + 76px));
    content: "";
    height: 260px;
    opacity: 0.1;
    pointer-events: none;
    position: fixed;
    left: 50%;
    transform: translateX(-50%) scaleX(-1);
    width: 330px;
    z-index: 0;
  }

  .stage-wrap {
    aspect-ratio: 16 / 9;
    flex: 0 0 auto;
    height: auto;
    overflow: hidden;
    position: relative;
    width: 100vw;
    z-index: 1;
  }

  .hud {
    display: grid;
    left: 8px;
    position: fixed;
    right: 8px;
    top: max(8px, env(safe-area-inset-top));
    z-index: 30;
  }

  .touch-controls {
    background: transparent;
    border-radius: 0;
    display: block;
    height: 62px;
    left: 0;
    margin: 0;
    padding: 0;
    pointer-events: none;
    position: fixed;
    right: 0;
    --touch-button-font-size: clamp(18px, 4.3vw, 24px);
    width: 100%;
    z-index: 20;
  }

  .touch-controls button {
    display: flex;
    font-size: var(--touch-button-font-size);
    height: 62px;
    position: absolute;
    width: clamp(130px, 42vw, 168px);
  }

  .touch-controls .jump {
    bottom: 0;
    left: max(14px, env(safe-area-inset-left));
  }

  .touch-controls .attack {
    bottom: 0;
    right: max(14px, env(safe-area-inset-right));
    width: clamp(130px, 42vw, 168px);
  }

  .message {
    inset: 0;
    justify-content: flex-start;
    overflow-y: auto;
    padding-top: 12px;
    position: fixed;
  }

  .message h1 {
    font-size: clamp(24px, 7vw, 32px);
    margin-top: 42px;
    max-width: calc(100% - 24px);
  }

  .message p {
    font-size: 13px;
    max-width: 18em;
    overflow-wrap: anywhere;
    word-break: normal;
  }

  .message button {
    display: inline-block;
  }

  .stage-select {
    display: grid;
    gap: 6px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-bottom: 8px;
    max-width: min(420px, calc(100% - 24px));
    width: 100%;
  }

  .stage-select button {
    min-width: 0;
    padding: 7px 6px;
    width: 100%;
  }

  .stage-select button span:first-child {
    font-size: 12px;
  }

  .stage-select button span:last-child {
    font-size: 11px;
  }

  .record-panel {
    gap: 3px;
    margin-bottom: 8px;
    max-width: min(240px, calc(100% - 24px));
    padding: 7px 9px;
  }

  .record-panel div {
    font-size: 12px;
  }

  .rotate-hint {
    display: none;
  }
}

@media (min-width: 761px) {
  html:not(.is-touch) .game-shell {
    height: auto;
    max-width: 1180px;
    width: min(100%, 1180px);
  }

  html:not(.is-touch) .stage-wrap {
    aspect-ratio: 16 / 9;
    border-width: 3px;
    border-radius: 8px;
    box-shadow: 0 18px 36px rgba(22, 53, 45, 0.28);
    height: auto;
    min-height: 0;
    width: 100%;
  }

  html:not(.is-touch) .message {
    justify-content: center;
    overflow: hidden;
    padding: 20px;
    position: absolute;
  }

  html:not(.is-touch) .controls-guide {
    display: grid;
    grid-template-columns: 1fr;
    margin: 0;
    max-width: 190px;
    position: absolute;
    right: 18px;
    top: 150px;
    width: 190px;
  }

  html:not(.is-touch) .record-panel {
    margin: 0;
    max-width: 240px;
    padding: 28px 10px 8px;
    position: absolute;
    right: 18px;
    top: 30px;
    width: 240px;
  }
}
