:root {
  --bg: #dde2e9;
  --panel: #d2d8e2;
  --text: #151821;
  --muted: #525a6b;
  --line: #b8c0cf;
  --card: #eef1f5;
  --shadow: 0 6px 20px rgba(15, 23, 42, 0.08);
  --radius: 20px;
  --left-width: 360px;
  --success: #237a45;
  --error: #a63a3a;
}

* { box-sizing: border-box; }

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--app-bg, var(--bg));
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.home-description {
  margin: -0.5rem 0 0;
  font-size: 1.05rem;
  line-height: 1.45;
  color: var(--muted);
}

.home-branding {
  width: 100%;
  max-width: 360px;
  padding: 18px;
}

.home-random {
  display: flex;
  justify-content: center;
  margin-top: 0.45rem;
}

.home-tags {
  display: flex;
  justify-content: center;
}

.shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

.left-column {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--left-width);
  height: 100vh;
  background: var(--panel);
  border-right: 1px solid rgba(15, 23, 42, 0.06);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.left-header {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 28px;
}

.home-panel-text {
  margin-top: 22px;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.55;
}

.home-panel-text p {
  margin: 0 0 14px;
}

.app-title {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.15;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.app-title-button {
  display: block;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.app-title-button:hover { opacity: 0.72; }

.app-title-button:focus-visible {
  outline: 2px solid rgba(15, 23, 42, 0.35);
  outline-offset: 4px;
  border-radius: 6px;
}

.app-subtitle {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.game-panel-compact {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.game-line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

.game-label {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.game-value {
  color: #151821;
  font-size: 1rem;
  font-weight: 800;
  text-align: right;
}

.control-btn-left {
  margin-top: 18px;
  padding: 0.85rem 1.25rem;
  border-radius: 999px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: #ffffff;
  color: #2f3440;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.control-btn-left:hover {
  transform: translateY(-1px);
  background: #f8fafc;
}

.game-mode {
  font-size: 0.95rem;
  font-weight: 800;
  color: #2f3440;
}

.game-question,
.game-score {
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1.1;
  color: #151821;
}

.game-question-label,
.game-score-label {
  margin-top: -10px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
}

.game-fails {
  margin-top: 4px;
  font-size: 0.95rem;
  font-weight: 700;
  color: #2f3440;
}

.left-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px 22px 28px;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.right-column {
  position: fixed;
  top: 0;
  left: var(--left-width);
  right: 0;
  height: 100vh;
  overflow: hidden;
  padding: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.right-fixed {
  width: 100%;
  max-width: 980px;
  height: 78vh;
  display: flex;
  align-items: stretch;
  justify-content: center;
}

.empty,
.loading,
.error {
  width: 100%;
  height: 100%;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.error { color: #7a1f1f; }

.card {
  width: 100%;
  height: 100%;
  background: var(--card);
  border-radius: 22px;
  box-shadow: var(--shadow);
  overflow: hidden;
  border: 1px solid rgba(15, 23, 42, 0.08);
  position: relative;
}

.card-inner {
  display: grid;
  grid-template-columns: minmax(280px, 400px) 1fr;
  height: 100%;
}

.media-column {
  background: #edf1f5;
  padding: 22px;
  overflow-y: auto;
}

.media-column img {
  width: 100%;
  aspect-ratio: 1 / 1;
  display: block;
  border-radius: 16px;
  object-fit: cover;
  object-position: center;
}

.question-card .media-column {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.question-card .media-column img,
.question-card .hard-mode-image,
.question-card .test-player {
  width: min(100%, 340px);
  max-width: 100%;
}

.question-card .media-column img,
.question-card .hard-mode-image {
  aspect-ratio: 1 / 1;
  display: block;
  border-radius: 16px;
  object-fit: cover;
  object-position: center;
  margin-top: 10px;
}

.question-card .test-player {
  margin-top: 18px;
}

.no-image {
  min-height: 260px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-style: italic;
}

.content-column {
  padding: 30px 34px 32px;
  overflow-y: auto;
  min-height: 0;
}

.home-content {
  background: #ffffff;
  color: var(--text);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2.05rem;
}

.home-media {
  background: var(--app-accent, #8b6a43);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
}

.home-title {
  margin: 0 0 0.75rem 0;
  font-size: 2.8rem;
  line-height: 1.02;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: #ffffff;
}

.home-subtitle {
  margin: 0;
  font-size: 1.1rem;
  line-height: 1.5;
  color: rgba(255,255,255,0.96);
}

.home-section { display: flex; flex-direction: column; gap: 0.8rem; }
.home-section-title { margin: 0; font-size: 1rem; font-weight: 700; }

.mode-grid,
.difficulty-grid,
.options-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.mode-grid,
.difficulty-grid {
  margin-top: 2px;
}

.options-grid {
  margin-top: 38px;
}

.tag,
.option-button,
.primary-button,
.next-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #ffffff;
  border: 1px solid rgba(15, 23, 42, 0.12);
  color: #2f3440;
  font: inherit;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
  transition: all 0.18s ease;
}

.tag:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
}

.next-row {
  display: flex;
  justify-content: center;
  margin-top: 10px;
}

.tag { padding: 0.75rem 1rem; font-size: 0.95rem; }
.option-button { padding: 0.95rem 1.15rem; font-size: 1.02rem; min-height: 48px; }
.primary-button,
.next-button { padding: 0.9rem 1.25rem; font-size: 1rem; }

.tag:hover,
.option-button:hover,
.primary-button:hover,
.next-button:hover:not(:disabled) {
  transform: translateY(-1px);
  background: #f8fafc;
}

.tag.active {
  background: var(--app-accent, #2f3440);
  color: #ffffff;
  border-color: var(--app-accent, #2f3440);
}

.option-button.correct {
  background: var(--question-accent-dark);
  border-color: var(--question-accent-dark);
  color: #ffffff;
}

.option-button.wrong {
  background: #4b5563;
  border-color: #4b5563;
  color: #ffffff;
}

.option-button:disabled { cursor: default; }
.next-button:disabled { opacity: 0.45; cursor: default; }

.question-kicker {
  margin: 0 0 42px;
  color: var(--question-accent-dark);
  font-weight: 800;
  font-size: 1.35rem;
  text-transform: none;
  letter-spacing: 0;
  text-align: center;
}

.author {
  margin: 0 0 6px;
  font-family: "PT Sans Narrow", "Arial Narrow", Arial, sans-serif;
  font-size: 1.5rem;
  line-height: 1.15;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #2f3440;
  margin-top: 0;
}

.work-title {
  margin: 0 0 16px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.2rem;
  line-height: 1.25;
  font-weight: 400;
  color: #4b5563;
  position: relative;
  padding-left: 14px;
}

.reveal-info {
  min-height: 90px;
  margin-bottom: 28px;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.reveal-info.is-visible {
  opacity: 1;
}

.work-title::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.22em;
  width: 5px;
  height: 1.05em;
  border-radius: 999px;
  background: var(--question-accent, #c9b79c);
}

.hidden-value {
  display: inline-flex;
  min-width: 110px;
  height: 1.05em;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.13);
  vertical-align: -0.12em;
}

.meta-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 20px 0 26px;
}

.text {
  font-size: 1rem;
  line-height: 1.7;
  white-space: pre-line;
  color: #2f3440;
}

.primary-start {
  font-size: 1.05rem;
  padding: 0.85rem 1.3rem;
  background: var(--app-accent, #8b6a43);
  border-color: var(--app-accent, #8b6a43);
  color: #ffffff;
}

.primary-start:hover {
  transform: translateY(-1px);
  background: var(--app-accent, #8b6a43);
  border-color: var(--app-accent, #8b6a43);
  color: #ffffff;
}

.player {
  margin-top: 16px;
}

.controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.icon {
  width: 18px;
  height: 18px;
  display: block;
}

.control-btn {
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: #ffffff;
  color: #2f3440;
  border-radius: 999px;
  width: 38px;
  height: 38px;
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.18s ease;
}

.control-btn:hover {
  background: #e9eef6;
  transform: translateY(-1px);
}

.play-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.play-symbol {
  position: absolute;
  width: 22px;
  height: 22px;
}

.icon-pause {
  display: none;
}

.play-btn.is-playing .icon-play {
  display: none;
}

.play-btn.is-playing .icon-pause {
  display: block;
}

.play-btn .icon {
  width: 22px;
  height: 22px;
}

.play-btn:hover {
  background: #252a35;
}

.progress-wrap {
  margin-top: 14px;
}

.progress-bar {
  position: relative;
  height: 6px;
  background: #e3e7ef;
  border-radius: 999px;
  overflow: hidden;
  cursor: pointer;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: #2f3440;
  transition: width 0.1s linear;
}

.time-row {
  display: flex;
  justify-content: flex-start;
  margin-top: 6px;
  font-size: 0.75rem;
  color: #6b7280;
}

.audio-wrap audio { width: 100%; }

.game-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.panel-card {
  background: rgba(255,255,255,0.45);
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 16px;
  padding: 14px;
}

.panel-label {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}

.panel-value {
  font-weight: 800;
  font-size: 1.15rem;
}

.question-year {
  margin: 8px 0 24px;
  font-size: 1.05rem;
  color: var(--muted);
  font-weight: 700;
}

.feedback {
  min-height: 1.5rem;
  margin: 24px 0 24px;
  text-align: center;
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.feedback.is-success {
  color: var(--question-accent-dark);
}

.feedback.is-error {
  color: var(--error);
}

.rhythm-legend {
  margin-top: 28px;
  margin-left: 12px;
  padding-top: 18px;
  border-top: 1px solid rgba(255,255,255,0.25);
  font-size: 0.82rem;
  line-height: 1.6;
  opacity: 0.95;
}

.rhythm-legend div {
  margin-bottom: 6px;
}

.rhythm-legend strong {
  font-weight: 800;
}

.end-left-panel .game-line {
  border-bottom-color: rgba(255, 255, 255, 0.22);
}

.end-left-panel .game-label,
.end-left-panel .game-value {
  color: #ffffff;
}

.end-left-panel .control-btn-left {
  background: rgba(255, 255, 255, 0.92);
  color: #2f3440;
  border-color: rgba(255, 255, 255, 0.92);
}

.end-left-panel .control-btn-left:hover {
  background: #ffffff;
  color: #2f3440;
}

.end-card {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--app-accent, #8b6a43);
  color: #ffffff;
}

.end-panel,
.multiplayer-end-panel {
  width: 100%;
  max-width: 680px;
  text-align: center;
  padding: 42px;
}

.end-kicker {
  margin: 0 0 12px;
  font-size: 1.15rem;
  font-weight: 800;
  opacity: 0.9;
}

.end-score {
  margin: 0;
  font-size: 5rem;
  line-height: 1;
  font-weight: 800;
  letter-spacing: -0.06em;
}

.end-label {
  margin: 6px 0 24px;
  font-size: 1.2rem;
  font-weight: 700;
  opacity: 0.9;
}

.end-summary {
  margin: 0 0 28px;
  font-size: 1rem;
  line-height: 1.5;
  opacity: 0.92;
}

.end-button {
  background: #ffffff;
  color: var(--app-accent, #8b6a43);
  border-color: #ffffff;
}

.end-button:hover {
  transform: translateY(-1px);
  background: #ffffff;
  color: var(--app-accent, #8b6a43);
}

.test-player {
  margin-top: 18px;
  padding: 0;
  background: transparent;
  border-radius: 0;
}

.test-controls {
  justify-content: center;
  margin-bottom: 10px;
}

.test-play-button {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  font-size: 0.95rem;
}

.test-progress {
  height: 7px;
  cursor: default;
}

.test-progress-fill {
  background: var(--question-accent-dark, #2f3440);
}

.test-time {
  color: #2f3440;
  font-weight: 700;
}

.secondary-home-link {
  position: absolute;
  right: 22px;
  bottom: 18px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  opacity: 0.65;
}

.secondary-home-link:hover {
  opacity: 1;
  color: var(--app-accent);
}

.player-name-list {
  display: grid;
  gap: 10px;
  margin: 18px 0;
}

.player-name-input {
  width: 100%;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 999px;
  padding: 0.75rem 1rem;
  font: inherit;
}

.multiplayer-instruction {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.4;
}

.player-scoreboard {
  margin-top: 12px;
  display: grid;
  gap: 8px;
}

.player-score-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.92rem;
  font-weight: 700;
  opacity: 0.72;
}

.player-score-line.active {
  opacity: 1;
}

.player-score-line strong {
  font-weight: 800;
}

.end-title {
  margin: 0 0 24px;
  font-size: 2rem;
  font-weight: 800;
}

.multiplayer-ranking {
  width: min(520px, 100%);
  margin: 0 auto 28px;
  display: grid;
  gap: 10px;
}

.ranking-line {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
  font-weight: 700;
}

.ranking-line strong {
  font-weight: 800;
}

.end-actions {
  width: min(420px, 100%);
  margin: 0 auto;
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.secondary-end-button {
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 999px;
  background: #ffffff;
  color: #2f3440;
  padding: 0.85rem 1.25rem;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.secondary-end-button:hover {
  transform: translateY(-1px);
}

@media (max-width: 980px) {
  html, body { overflow: auto; }

  .shell { width: 100%; height: auto; overflow: visible; }
  .left-column, .right-column { position: static; width: 100%; height: auto; }
  .left-column { border-right: 0; border-bottom: 1px solid var(--line); }
  .left-scroll { max-height: none; }
  .right-column { padding: 18px; display: block; overflow: visible; }
  .right-fixed { max-width: none; width: 100%; height: auto; display: block; }
  .card { height: auto; }
  .card-inner { grid-template-columns: 1fr; height: auto; }
  .media-column, .content-column { overflow: visible; }

  .question-card .media-column {
    padding: 18px;
  }

  .question-card .media-column img,
  .question-card .hard-mode-image,
  .question-card .test-player {
    width: min(100%, 300px);
    max-width: calc(100vw - 72px);
  }

  .question-card .media-column img,
  .question-card .hard-mode-image {
    margin-top: 12px;
  }

  .home-title {
    font-size: 2rem;
    line-height: 1.05;
  }

  .home-subtitle {
    font-size: 0.95rem;
    line-height: 1.35;
  }
  
  .option-button {
    white-space: normal;
    text-align: center;
    line-height: 1.25;
  }

  .options-grid {
    width: 100%;
  }  
}
