* {
  box-sizing: border-box;
}

@media (max-width: 700px) {
  body.friend-real-battle .battle-screen { padding-inline: 10px; }
  body.friend-real-battle .friend-real-timer-line { gap: 8px; }
  body.friend-real-battle .friend-real-timer { font-size: clamp(52px, 19vw, 88px); }
  body.friend-real-battle .friend-real-edit-button { min-width: 58px; padding-inline: 10px; }
  body.friend-real-battle .multiplayer-roster { margin-block: 8px; padding: 10px; }
  body.friend-real-battle .multiplayer-roster:not(.expanded) .multiplayer-roster-list { display: none; }
  body.friend-real-battle .multiplayer-roster-toggle::after { content: " +"; }
  body.friend-real-battle .multiplayer-roster.expanded .multiplayer-roster-toggle::after { content: " -"; }
  body.friend-real-battle .friend-real-edit-actions { flex-wrap: wrap; }
  body.friend-real-battle .friend-real-edit-actions button { flex: 1 1 42%; }
}

body.touch-device.friend-real-battle .multiplayer-roster:not(.expanded) .multiplayer-roster-list { display: none; }
body.touch-device.friend-real-battle .multiplayer-roster-toggle::after { content: " +"; }
body.touch-device.friend-real-battle .multiplayer-roster.expanded .multiplayer-roster-toggle::after { content: " -"; }

@media (min-width: 901px) {
  body.real-timer-clean {
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    touch-action: none;
    overscroll-behavior: none;
  }

  body.real-timer-clean main,
  body.real-timer-clean main * {
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    touch-action: none;
  }

  body.real-timer-clean header,
  body.real-timer-clean .left-panel,
  body.real-timer-clean .battle-screen,
  body.real-timer-clean footer,
  body.real-timer-clean .opponent-cube-panel,
  body.real-timer-clean .move-input,
  body.real-timer-clean .real-cube-instruction,
  body.real-timer-clean .real-cube-timer-button {
    display: none !important;
  }

  body.real-timer-clean main {
    position: fixed !important;
    z-index: 100;
    inset: 0;
    display: block !important;
    min-height: 100dvh !important;
    padding: 0 !important;
    touch-action: none;
  }

  body.real-timer-clean .cube-area,
  body.real-timer-clean #cubeContainer {
    position: absolute !important;
    inset: 0;
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    max-height: none !important;
    transform: none !important;
    pointer-events: none;
  }

  body.real-timer-clean .panel {
    position: absolute !important;
    z-index: 2;
    inset: 0;
    display: flex !important;
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0;
    background: transparent;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    pointer-events: none;
    transform: none !important;
  }

  body.real-timer-clean .panel > * {
    display: none !important;
  }

  body.real-timer-clean.real-timer-solving .panel .timer {
    display: block !important;
    margin: 0;
    font-size: clamp(72px, 16vw, 150px);
  }

  body.real-timer-clean .battle-inspection-overlay {
    top: 22%;
  }

  body.real-timer-clean .panel .buttons {
    position: absolute;
    right: 24px;
    bottom: 24px;
    display: block !important;
    width: auto;
    margin: 0;
    pointer-events: auto;
  }

  body.real-timer-clean .panel .buttons > * {
    display: none !important;
  }

  body.real-timer-clean .panel #resetBtn {
    display: block !important;
    min-width: 128px;
    margin: 0;
    padding: 16px 22px;
    background: #8f2929;
  }
}

body {
  --bg: #eaffc9;
  --surface: rgba(247, 255, 240, 0.92);
  --surface-2: rgba(255, 255, 255, 0.72);
  --border: #9ab6c3;
  --text: #111;
  --text-muted: rgba(17, 17, 17, 0.68);
  --primary: #1e6f9e;
  --primary-hover: #185c85;
  --danger: #8d2530;
  --danger-hover: #75202a;
  margin: 0;
  font-family: Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
}

body.custom-background::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  background: rgba(234, 255, 201, 0.72);
  pointer-events: none;
}

body.dark.custom-background::before {
  background: rgba(0, 0, 0, 0.62);
}

.app {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.battle-screen {
  display: none;
  width: min(1080px, calc(100% - 32px));
  margin: 16px auto 0;
}

header {
  position: relative;
  z-index: 5;
  text-align: center;
  padding: 16px;
}

.header-action {
  margin-top: 4px;
  padding: 9px 14px;
  font-size: 14px;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  max-width: 560px;
  margin: 0 auto;
}

h1 {
  margin: 0 0 10px;
  font-size: clamp(32px, 5vw, 54px);
  font-weight: 800;
}

.scramble {
  min-height: 32px;
  font-size: clamp(20px, 3vw, 40px);
  font-weight: bold;
  line-height: 1.35;
  overflow-wrap: anywhere;
  word-break: normal;
  max-width: min(1120px, calc(100vw - 32px));
  margin: 0 auto 8px;
  padding: 8px 16px;
}

main {
  position: relative;
  flex: 1;
  display: grid;
  place-items: center;
  padding: 16px;
}

.left-panel {
  position: absolute;
  left: 48px;
  top: 16px;
  width: clamp(280px, 22vw, 380px);
  max-height: calc(100vh - 180px);
  overflow-y: auto;
  padding: 16px;
  border: 1px solid rgba(30, 95, 139, 0.22);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 12px 32px rgba(25, 63, 82, 0.1);
  scrollbar-gutter: stable;
  z-index: 2;
}

body.custom-background .left-panel,
body.custom-background .panel,
body.custom-background .modal-content,
body.custom-background .battle-player-card,
body.custom-background .battle-rematch {
  background: rgba(247, 255, 240, 0.84);
  backdrop-filter: blur(2px);
}

body.dark.custom-background .left-panel,
body.dark.custom-background .panel,
body.dark.custom-background .modal-content,
body.dark.custom-background .battle-player-card,
body.dark.custom-background .battle-rematch {
  background: rgba(24, 55, 71, 0.9);
}

.cube-area {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  transform: translateY(-80px);
  z-index: 1;
}

#cubeContainer {
  position: relative;
  width: min(52vw, 860px);
  height: min(52vw, 860px);
  margin: 0 auto;
  touch-action: manipulation;
  user-select: none;
}

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

.move-input {
  display: none;
  width: min(92vw, 520px);
  border: 2px solid #111;
  border-radius: 8px;
  padding: 12px 14px;
  margin-top: 10px;
  font-size: 16px;
  text-align: center;
  background: white;
  color: #111;
}

.panel {
  position: absolute;
  right: 48px;
  top: 16px;
  transform: none;
  width: clamp(260px, 20vw, 340px);
  max-height: calc(100vh - 180px);
  overflow-y: auto;
  padding: 16px;
  border: 1px solid rgba(30, 95, 139, 0.22);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 12px 32px rgba(25, 63, 82, 0.1);
  scrollbar-gutter: stable;
  z-index: 2;
}

.normal-real-history-column {
  display: contents;
}

.timer {
  font-family: "Courier New", monospace;
  font-size: 52px;
  font-weight: bold;
  text-align: center;
  margin-bottom: 6px;
}

.tps-display {
  font-family: "Courier New", monospace;
  font-size: 20px;
  font-weight: bold;
  text-align: center;
  margin-bottom: 16px;
}

.moves-display {
  font-family: "Courier New", monospace;
  font-size: 18px;
  font-weight: bold;
  text-align: center;
  margin: -10px 0 16px;
}

.buttons {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.buttons button {
  width: 100%;
}

button {
  border: none;
  border-radius: 10px;
  padding: 12px;
  font-size: 16px;
  cursor: pointer;
  background: #111;
  color: white;
  font-weight: 700;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, opacity 0.15s ease, transform 0.15s ease;
}

button:hover {
  opacity: 0.92;
  transform: translateY(-1px);
}

.last-move {
  margin-top: 18px;
  font-size: 16px;
  text-align: left;
}

h2 {
  font-size: 20px;
  margin: 22px 0 12px;
}

.left-panel h2,
.panel h2 {
  text-align: center;
}

#timeList {
  padding: 0 10px 0 24px;
  max-height: min(28vh, 220px);
  overflow-y: auto;
  margin: 0 0 18px;
  scrollbar-gutter: stable;
}

.history-item {
  margin: 8px 0;
  padding-right: 4px;
}

.history-empty {
  margin: 8px 0 14px;
  color: inherit;
  opacity: 0.78;
  font-style: italic;
}

body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) #timeList,
body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) #scrambleHistoryList {
  display: block !important;
  min-height: 28px;
  visibility: visible !important;
  opacity: 1 !important;
}

.history-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.history-row > span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.history-menu-button {
  flex: 0 0 auto;
  min-width: 32px;
  min-height: 32px;
  margin-right: 2px;
  padding: 2px 8px;
  border-radius: 5px;
  font-size: 22px;
  line-height: 1;
}

.solve-details {
  margin: 6px 0 8px;
  padding: 8px;
  border-left: 3px solid #1e5f8b;
  background: rgba(255, 255, 255, 0.55);
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

footer {
  text-align: center;
  padding: 12px;
  font-size: 14px;
  opacity: 0.8;
}

.footer-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 16px;
  margin-top: 10px;
}

.footer-nav a {
  padding: 7px 9px;
  border-radius: 4px;
  color: inherit;
  font-weight: bold;
  text-decoration: none;
}

.footer-nav a:hover {
  background: rgba(0, 0, 0, 0.1);
}

body.dark .footer-nav a:hover {
  background: rgba(255, 255, 255, 0.14);
}

.info-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.info-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: min(920px, calc(100% - 32px));
  margin: 0 auto;
  padding: 18px 0;
}

.info-header h1 {
  margin: 0;
}

.info-content {
  position: static;
  display: block;
  flex: initial;
  width: min(760px, calc(100% - 32px));
  margin: 28px auto;
  padding: 24px;
  border: 2px solid #1e5f8b;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  line-height: 1.6;
}

.info-content h2 {
  margin: 24px 0 8px;
}

.info-content h2:first-child {
  margin-top: 0;
}

.info-content ul {
  padding-left: 22px;
}

.page-return {
  align-self: center;
  width: min(760px, calc(100% - 32px));
  margin: 0 auto 36px;
  text-align: center;
}

.page-return a {
  display: inline-block;
  padding: 12px 18px;
  border-radius: 8px;
  background: #111;
  color: #fff;
  font-weight: bold;
  text-decoration: none;
}

body.dark .info-content {
  border-color: #78c5ef;
  background: #183747;
}

body.dark .page-return a {
  background: #78c5ef;
  color: #111;
}

@media (max-width: 900px) {
  main {
    display: flex;
    flex-direction: column;
    align-items: center;
  }
}

/* Solo Real Cube layout: keep controls, preview, and history in normal flow. */
body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .panel {
  display: contents !important;
}

body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) #scrambleBtn,
body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) #resetBtn {
  display: none !important;
}

body.real-timer-clean.real-timer-clean .normal-real-history-column {
  display: contents !important;
}

body.real-timer-clean.real-timer-clean .normal-real-history-column > * {
  display: none !important;
}

body.real-timer-clean.real-timer-clean .normal-real-history-column > .buttons {
  display: block !important;
}

@media (min-width: 1101px) {
  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) main {
    display: grid;
    grid-template-columns: clamp(280px, 22vw, 380px) minmax(420px, 1fr) clamp(300px, 22vw, 380px);
    grid-template-rows: auto 1fr;
    gap: 18px 28px;
    align-items: start;
    min-height: calc(100vh - 170px);
    padding: 8px 48px 24px;
  }

  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .left-panel {
    position: static;
    grid-column: 1;
    grid-row: 1 / span 2;
    width: 100%;
    max-height: calc(100vh - 205px);
  }

  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .timer {
    position: static;
    grid-column: 2;
    grid-row: 1;
    align-self: end;
    margin: 28px 0 0;
    font-size: clamp(84px, 10vw, 156px);
    line-height: 1;
    transform: none;
    pointer-events: auto;
    touch-action: none;
  }

  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .cube-area {
    position: static;
    grid-column: 2;
    grid-row: 2;
    display: flex;
    width: 100%;
    transform: none;
  }

  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .real-cube-instruction,
  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .real-cube-timer-button,
  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .normal-real-scramble-net {
    position: static;
    inset: auto;
    transform: none;
  }

  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .real-cube-instruction {
    margin: 8px auto 0;
  }

  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .real-cube-timer-button {
    margin: 14px auto 0;
  }

  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .normal-real-scramble-net {
    width: min(100%, 420px);
    margin: 28px auto 0;
    padding: 10px;
  }

  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .normal-real-scramble-net .cube-net {
    --net-sticker-size: clamp(12px, 1.45vw, 22px);
  }

  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .normal-real-history-column {
    display: block;
    grid-column: 3;
    grid-row: 1 / span 2;
    width: 100%;
    max-height: calc(100vh - 205px);
    overflow-y: auto;
    padding: 18px 20px;
    scrollbar-gutter: stable;
  }

  body.custom-background.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .normal-real-history-column {
    background: rgba(247, 255, 240, 0.84);
    backdrop-filter: blur(2px);
  }

  body.dark.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .normal-real-history-column {
    background: rgba(28, 28, 28, 0.92);
  }

  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) #timeList {
    min-height: 132px;
    max-height: 220px;
  }

  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) #scrambleHistoryList {
    min-height: 108px;
    max-height: 180px;
  }
}

@media (max-width: 1100px) {
  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) main {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 10px 12px 24px;
  }

  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .timer {
    position: static;
    order: 1;
    width: 94vw;
    margin: 6px auto;
    font-size: clamp(64px, 20vw, 108px);
    transform: none;
    pointer-events: auto;
    touch-action: none;
  }

  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .cube-area {
    position: static;
    order: 2;
    display: flex;
    width: 94vw;
    transform: none;
  }

  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .real-cube-instruction,
  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .real-cube-timer-button,
  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .normal-real-scramble-net {
    position: static;
    inset: auto;
    transform: none;
  }

  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .normal-real-scramble-net {
    width: min(94vw, 520px);
    margin: 18px auto 0;
  }

  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .normal-real-history-column {
    display: block;
    order: 3;
    width: 94vw;
    max-height: none;
    overflow: visible;
    padding: 18px 20px;
  }

  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .left-panel {
    position: static;
    order: 4;
    width: 94vw;
    max-height: none;
  }

  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) #timeList,
  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) #scrambleHistoryList {
    min-height: 72px;
    max-height: 240px;
  }
}

@media (min-width: 901px) {
  body:not(.battle-mode):not(.normal-real-cube) main {
    min-height: calc(100dvh - 176px);
  }

  body:not(.battle-mode):not(.normal-real-cube) #cubeContainer {
    width: clamp(440px, 50vw, 820px);
    height: clamp(440px, 50vw, 820px);
  }
}

@media (max-width: 900px) {
  body:not(.battle-mode) .app {
    min-height: 100dvh;
  }

  body:not(.battle-mode) header {
    padding: 14px 10px 8px;
  }

  body:not(.battle-mode) main {
    gap: 10px;
  }

  body:not(.battle-mode) .cube-area {
    order: 1;
    width: 100%;
  }

  body:not(.battle-mode) .panel {
    order: 2;
  }

  body:not(.battle-mode) .left-panel {
    order: 3;
  }

  body:not(.battle-mode) .panel,
  body:not(.battle-mode) .left-panel {
    width: min(94vw, 560px);
    padding: 14px;
  }

  body:not(.battle-mode) .stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  body:not(.battle-mode) #timeList,
  body:not(.battle-mode) #scrambleHistoryList {
    max-height: 180px;
  }

  .friend-battle-flow {
    gap: 12px;
  }

  .friend-battle-card,
  .friend-room-share {
    padding: 14px;
  }
}

@media (max-width: 430px) {
  .header-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: min(100%, 390px);
  }

  #openBattleBtn {
    grid-column: 1 / -1;
  }

  body:not(.battle-mode) #cubeContainer {
    width: min(96vw, 52vh);
    height: min(96vw, 52vh);
  }

  body:not(.battle-mode) .timer {
    font-size: clamp(42px, 13vw, 58px);
  }

  body:not(.battle-mode) .stats {
    font-size: 13px;
  }

  .friend-room-id {
    font-size: 32px;
  }
}

body.real-timer-clean .normal-real-history-column {
  display: contents !important;
}

body.real-timer-clean .normal-real-history-column > * {
  display: none !important;
}

body.real-timer-clean .normal-real-history-column > .buttons {
  display: block !important;
}

body.real-timer-clean .normal-real-history-column {
  display: contents !important;
}

body.real-timer-clean .normal-real-history-column > * {
  display: none !important;
}

body.real-timer-clean .normal-real-history-column > .buttons {
  display: block !important;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 14px;
  font-size: 14px;
  font-weight: bold;
  text-align: center;
}

.stats div {
  min-width: 0;
  padding: 9px 6px;
  border: 1px solid rgba(30, 95, 139, 0.18);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.48);
  overflow-wrap: anywhere;
}

.theme-toggle {
  width: 100%;
  margin-bottom: 12px;
  background: #333;
}

.account-summary {
  margin-bottom: 16px;
}

.account-greeting {
  font-size: 18px;
  font-weight: bold;
  line-height: 1.3;
  margin-bottom: 6px;
}

.account-rank {
  font-size: 14px;
  font-weight: bold;
  opacity: 0.9;
}

.account-rating {
  margin-top: 6px;
  font-size: 15px;
  font-weight: bold;
  text-align: left;
}

.login-panel,
.online-ranking-panel,
.battle-panel {
  margin-bottom: 16px;
}

#playerNameInput,
#roomIdInput,
#roomUrlOutput {
  width: 100%;
  border: 2px solid #111;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 10px;
  font-size: 16px;
  background: white;
  color: #111;
}

.auth-buttons {
  margin-bottom: 14px;
}

.auth-status {
  font-size: 13px;
  line-height: 1.4;
  opacity: 0.85;
}

.user-count {
  margin-top: 8px;
  font-size: 13px;
  font-weight: bold;
  opacity: 0.8;
}

.profile-button {
  width: 100%;
  margin-top: 14px;
}

.feature-modal {
  z-index: 30;
}

.feature-content {
  width: min(980px, 100%);
  max-height: min(88vh, 900px);
}

.feature-content #onlineRankingList,
.feature-content #battleRatingList {
  max-height: none;
}

.feature-content #onlineRankingList {
  min-height: 120px;
}

.settings-section {
  margin-top: 24px;
}

.settings-section h3 {
  margin: 0 0 10px;
}

.settings-section label,
.settings-hint {
  display: block;
  margin: 0 0 8px;
  font-size: 14px;
  opacity: 0.82;
}

#animationSpeedSelect,
#normalTimerModeSelect {
  width: min(100%, 340px);
  border: 2px solid #111;
  border-radius: 6px;
  padding: 10px 12px;
  background: #fff;
  color: #111;
  font-size: 16px;
}

#cubeSizeInput {
  display: block;
  width: min(100%, 420px);
  margin: 10px 0 4px;
  accent-color: #286a96;
}

#cubeSizeValue {
  font-weight: 700;
  opacity: 1;
}

#backgroundImageInput {
  display: block;
  width: min(100%, 420px);
  margin: 6px 0 12px;
  font-size: 14px;
}

.background-remove {
  margin-top: 4px;
}

.key-bindings-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.key-binding-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 7px 8px;
  border: 1px solid #b7cbd6;
  border-radius: 5px;
  background: #fff;
  font-family: "Courier New", monospace;
}

.key-binding-key {
  min-width: 34px;
  padding: 4px 7px;
  border-radius: 4px;
  background: #e5eef4;
  text-align: center;
  font-weight: bold;
}

.key-binding-change {
  padding: 7px 9px;
  font-size: 13px;
}

.key-binding-change.is-listening {
  background: #1e5f8b;
  color: #fff;
}

.settings-section > .secondary-action {
  margin-top: 12px;
}

.app-modal[hidden] {
  display: none;
}

.app-modal {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.55);
}

.modal-content {
  width: min(760px, 100%);
  max-height: min(82vh, 820px);
  overflow-y: auto;
  border: 2px solid #1e5f8b;
  border-radius: 8px;
  padding: 20px;
  background: #f7fff0;
  color: #111;
}

.modal-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid #a6c2d0;
  padding-bottom: 10px;
}

.modal-heading h2,
.modal-content h3 {
  margin: 0;
}

.modal-content h3 {
  margin-top: 18px;
  font-size: 18px;
}

.modal-content p {
  line-height: 1.55;
}

.modal-close {
  padding: 8px 12px;
  font-size: 14px;
}

.key-map {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin-top: 10px;
}

.key-map span {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 7px;
  border: 1px solid #b7cbd6;
  border-radius: 4px;
  background: #fff;
  font-family: "Courier New", monospace;
}

.keyboard-controls-figure {
  margin: 14px 0 0;
}

.keyboard-controls-figure figcaption {
  margin-bottom: 10px;
  font-size: 17px;
  font-weight: 700;
}

.keyboard-controls-figure img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  border: 1px solid #6f8794;
  border-radius: 8px;
}

.keyboard-controls-tip {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-left: 3px solid #1e5f8b;
  background: rgba(30, 95, 139, 0.08);
}

body.dark .keyboard-controls-tip {
  border-left-color: #78c5ef;
  background: rgba(120, 197, 239, 0.1);
}

@media (max-width: 600px) {
  .keyboard-controls-figure figcaption {
    font-size: 15px;
  }

  .keyboard-controls-figure img {
    border-radius: 6px;
  }
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 18px;
  margin-top: 18px;
}

.profile-grid div {
  border-left: 3px solid #1e5f8b;
  padding-left: 8px;
}

.profile-grid dt {
  font-size: 12px;
  opacity: 0.7;
}

.profile-grid dd {
  margin: 3px 0 0;
  font-weight: bold;
}

.profile-section-title {
  margin: 24px 0 8px;
  font-size: 18px;
}

.primary-action,
#createRoomBtn,
#joinRoomBtn,
#randomBattleBtn,
#battleReadyBtn,
#openBattleBtn {
  background: var(--primary);
  color: #fff;
}

.primary-action:hover,
#createRoomBtn:hover,
#joinRoomBtn:hover,
#randomBattleBtn:hover,
#battleReadyBtn:hover,
#openBattleBtn:hover {
  background: var(--primary-hover);
}

.secondary-action,
.header-action.secondary-action,
#copyRoomIdBtn,
#copyRoomUrlBtn,
#openSettingsBtn,
#openRankingBtn,
#howToPlayBtn,
#cancelMatchBtn {
  border: 1px solid rgba(30, 95, 139, 0.32);
  background: var(--surface-2);
  color: var(--text);
}

.secondary-action:hover,
.header-action.secondary-action:hover,
#copyRoomIdBtn:hover,
#copyRoomUrlBtn:hover,
#openSettingsBtn:hover,
#openRankingBtn:hover,
#howToPlayBtn:hover,
#cancelMatchBtn:hover {
  border-color: var(--primary);
  background: rgba(30, 111, 158, 0.12);
}

.danger-action,
#clearTimesBtn,
#friendRealDnfBtn,
#friendRealRemoveBtn {
  background: var(--danger);
  color: #fff;
}

.danger-action:hover,
#clearTimesBtn:hover,
#friendRealDnfBtn:hover,
#friendRealRemoveBtn:hover {
  background: var(--danger-hover);
}

.battle-buttons {
  margin-bottom: 10px;
}

.battle-choice-tabs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin: 16px 0 18px;
  padding: 4px;
  border: 1px solid rgba(30, 95, 139, 0.22);
  border-radius: 10px;
  background: rgba(30, 95, 139, 0.07);
}

.battle-choice-tab {
  border-radius: 8px;
  padding: 10px 8px;
  background: transparent;
  color: var(--text);
  font-size: 14px;
}

.battle-choice-tab.active {
  background: var(--primary);
  color: #fff;
}

.friend-battle-flow {
  display: grid;
  gap: 14px;
}

.friend-battle-card,
.friend-room-share {
  padding: 16px;
  border: 1px solid rgba(30, 95, 139, 0.24);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.48);
}

.friend-battle-card h3 {
  margin: 0 0 12px;
  font-size: 18px;
}

.friend-battle-card button,
.friend-create-card button,
.friend-room-share button {
  width: 100%;
}

.friend-battle-divider {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

.friend-battle-divider::before,
.friend-battle-divider::after {
  content: "";
  height: 1px;
  background: rgba(30, 95, 139, 0.28);
}

.friend-room-share[hidden] {
  display: none;
}

.friend-room-share {
  text-align: center;
}

.friend-room-id-label {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
}

.friend-room-id {
  margin: 6px 0 12px;
  font-family: "Courier New", monospace;
  font-size: clamp(30px, 7vw, 44px);
  font-weight: 800;
  letter-spacing: 2px;
}

.battle-status {
  min-height: 24px;
  padding: 10px 12px;
  border: 1px solid rgba(30, 95, 139, 0.18);
  border-radius: 8px;
  background: rgba(30, 95, 139, 0.07);
}

.random-status {
  min-height: 20px;
  margin-bottom: 10px;
  font-size: 13px;
  font-weight: bold;
}

.battle-status,
.battle-players,
.battle-winner {
  font-size: 13px;
  line-height: 1.45;
  margin-top: 8px;
}

.battle-winner {
  font-weight: bold;
}

body.battle-mode {
  background: #d9f1ff;
}

body.battle-mode header,
body.battle-mode .left-panel,
body.battle-mode .panel,
body.battle-mode footer {
  display: none;
}

body.battle-mode .battle-screen {
  display: block;
}

body.battle-mode main {
  min-height: 0;
  padding-top: 4px;
}

body.battle-mode .cube-area {
  transform: none;
}

body.battle-mode #cubeContainer {
  width: min(50vw, 760px);
  height: min(50vw, 760px);
}

.opponent-cube-panel {
  display: none;
}

body.battle-mode .opponent-cube-panel {
  position: absolute;
  top: 50%;
  left: calc(100% + 18px);
  display: block;
  width: 210px;
  padding: 10px;
  border: 2px solid #8a4e25;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  text-align: center;
  transform: translateY(-50%);
}

.opponent-cube-panel h2 {
  margin: 0 0 8px;
  font-size: 16px;
}

#opponentCubeContainer {
  width: 186px;
  height: 186px;
  margin: 0 auto;
  pointer-events: none;
}

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

#opponentCubeStatus {
  min-height: 20px;
  margin-top: 8px;
  font-size: 12px;
  font-weight: bold;
  overflow-wrap: anywhere;
}

body.battle-mode .opponent-cube-panel.opponent-unavailable {
  opacity: 0.45;
}

.battle-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 2px solid #1e5f8b;
  padding-bottom: 10px;
}

.battle-heading h2 {
  margin: 0;
  font-size: 30px;
}

.battle-heading p,
.battle-scramble {
  margin: 5px 0 0;
  font-weight: bold;
}

.ranked-time-limit {
  min-height: 24px;
  margin: 8px 0;
  color: #164c70;
  text-align: center;
  font-family: "Courier New", monospace;
  font-size: 16px;
  font-weight: bold;
}

.battle-mode-label {
  display: inline-block;
  margin-top: 6px;
  padding: 4px 8px;
  border-radius: 4px;
  background: #1e5f8b;
  color: #fff;
  font-size: 13px;
  font-weight: bold;
}

.battle-mode-actions {
  display: flex;
  gap: 8px;
}

.battle-mode-actions button {
  padding: 9px 12px;
  font-size: 14px;
}

.host-start-button {
  background: #1f8a4c;
  color: #fff;
  font-weight: 700;
}

.multiplayer-roster {
  margin: 14px 0;
  padding: 14px;
  border: 2px solid rgba(17, 17, 17, 0.3);
  border-radius: 6px;
}

.multiplayer-roster h2 {
  margin: 0 0 10px;
  text-align: center;
  font-size: 18px;
}

.multiplayer-roster-toggle {
  display: block;
  width: 100%;
  margin: 0 0 10px;
  padding: 6px 10px;
  color: inherit;
  background: transparent;
  text-align: center;
  font-size: clamp(22px, 3vw, 30px);
  font-weight: 700;
}

.friend-real-timer-panel { width: min(100%, 900px); margin: 4px auto 12px; text-align: center; }
.friend-real-timer-panel[hidden], .friend-real-operation[hidden] { display: none; }
.friend-real-timer-line { display: flex; justify-content: center; align-items: center; gap: 14px; }
.friend-real-timer { min-width: 5ch; font-family: "Courier New", monospace; font-size: clamp(58px, 10vw, 132px); font-weight: 700; line-height: 1; }
.friend-real-edit-button { width: auto; min-width: 72px; margin: 0; }
.friend-real-edit-menu { width: min(100%, 520px); margin: 12px auto 0; padding: 14px; border: 2px solid #286a96; border-radius: 6px; background: rgba(255, 255, 255, 0.94); }
.friend-real-manual-entry, .friend-real-edit-actions { display: flex; gap: 10px; margin-top: 10px; }
.friend-real-edit-menu label[hidden],
.friend-real-manual-entry[hidden],
.friend-real-edit-actions[hidden],
.friend-real-manual-entry button[hidden] { display: none; }
.friend-real-manual-entry input { flex: 1; min-width: 0; }
.friend-real-manual-entry button, .friend-real-edit-actions button { margin: 0; }
.friend-real-edit-actions button { flex: 1; }
.friend-real-operation { margin: 8px auto 16px; text-align: center; font-size: clamp(17px, 2.2vw, 24px); font-weight: 700; }
body.dark .friend-real-edit-menu { color: #f5f5f5; background: rgba(16, 33, 44, 0.96); border-color: #78c5ef; }
body.friend-real-battle #hostStartBattleBtn, body.friend-real-battle #battleReadyBtn, body.friend-real-battle .friend-real-controls { display: none !important; }

.battle-settings-button {
  min-width: 104px;
  font-weight: 700;
}

.friend-battle-settings-content {
  width: min(92vw, 620px);
  max-height: min(88vh, 820px);
  overflow-y: auto;
}

.battle-settings-section {
  padding: 16px 0;
  border-bottom: 1px solid rgba(17, 17, 17, 0.22);
}

.battle-settings-section:last-child { border-bottom: 0; }
.battle-settings-section h3 { margin: 0 0 12px; }
.battle-settings-section select { width: 100%; min-height: 46px; margin-top: 8px; padding: 8px 10px; }
.battle-settings-section button { width: 100%; margin: 0; }
.danger-action { background: #8d2530; color: #fff; }

body.dark .battle-settings-section { border-color: rgba(255, 255, 255, 0.24); }
body.dark .battle-settings-section select { color: #f5f5f5; background: #162b36; border-color: #78c5ef; }

.friend-real-history-panel[hidden] { display: none; }

.friend-real-main-layout,
.friend-real-center-column {
  display: contents;
}

body.friend-real-battle .battle-screen {
  display: block;
}

body.friend-real-battle .friend-real-main-layout {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr) minmax(220px, 300px);
  gap: 22px;
  width: 100%;
  margin-top: 14px;
  align-items: start;
}

body.friend-real-battle .friend-real-center-column {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 14px;
  align-items: stretch;
}

body.friend-real-battle .friend-real-history-panel {
  width: 100%;
  min-width: 0;
  min-height: 420px;
  max-height: 590px;
  padding: 16px;
  overflow-y: auto;
  color: inherit;
  background: transparent;
  border: 1px solid rgba(40, 106, 150, 0.42);
  justify-self: start;
}

body.friend-real-battle .friend-real-room-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 20px;
}
body.friend-real-battle .friend-real-room-stats div {
  padding: 10px 6px;
  text-align: center;
  border: 1px solid rgba(120, 197, 239, 0.5);
  background: rgba(120, 197, 239, 0.1);
}
body.friend-real-battle .friend-real-room-stats dt { font-size: 13px; font-weight: 700; }
body.friend-real-battle .friend-real-room-stats dd { margin: 4px 0 0; font-size: 20px; font-weight: 700; }
body.friend-real-battle .friend-real-history-panel h3 { margin: 0 0 12px; text-align: center; }
body.friend-real-battle .friend-real-history-panel ol { margin: 0; padding-left: 28px; }
body.friend-real-battle .friend-real-history-panel li { margin: 0 0 10px; line-height: 1.35; overflow-wrap: anywhere; }
body.friend-real-battle .friend-real-timer-panel { width: 100%; min-width: 0; margin: 18px 0 0; }
body.friend-real-battle .friend-real-timer-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 80px;
  width: 100%;
  align-items: center;
  gap: 12px;
}
body.friend-real-battle .friend-real-timer-cell {
  position: relative;
  grid-column: 1;
  min-width: 0;
}
body.friend-real-battle .friend-real-timer {
  justify-self: center;
  transition: color 120ms ease;
}

body.friend-real-battle.inspection-hold-red #friendRealTimerDisplay {
  color: #e53935 !important;
}

body.friend-real-battle.inspection-hold-green #friendRealTimerDisplay {
  color: #34c759 !important;
}

body.normal-real-cube:not(.battle-mode):not(.real-timer-clean).inspection-hold-red #timerDisplay {
  color: #e53935 !important;
}

body.normal-real-cube:not(.battle-mode):not(.real-timer-clean).inspection-hold-green #timerDisplay {
  color: #34c759 !important;
}
body.friend-real-battle .friend-real-edit-button {
  grid-column: 2;
  justify-self: stretch;
  width: 80px;
  min-width: 80px;
  margin: 0;
}
body.friend-real-battle .friend-real-timer { font-size: clamp(82px, 8vw, 128px); }
body.friend-real-battle .multiplayer-roster { width: 100%; margin: 0; border-color: #62c7f5; }
body.friend-real-battle .multiplayer-roster-list { grid-template-columns: 1fr; max-height: 270px; }
body.friend-real-battle .multiplayer-roster-row { min-height: 66px; font-size: clamp(16px, 1.4vw, 22px); }
body.friend-real-battle .scramble-net-panel {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  max-width: 300px;
  margin: 18px 0 0;
  padding: 10px;
  justify-self: end;
  overflow: hidden;
}
body.friend-real-battle .scramble-net-panel .cube-net {
  --net-sticker-size: clamp(10px, 1.05vw, 17px);
  gap: 2px;
}
body.friend-real-battle .scramble-net-panel h3 { margin: 0 0 8px; font-size: 16px; }
body.friend-real-battle .battle-scramble { font-size: clamp(24px, 3vw, 44px); line-height: 1.35; overflow-wrap: anywhere; }

.friend-virtual-battle-stage[hidden] {
  display: none;
}

body.friend-virtual-battle .friend-virtual-battle-stage {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  grid-template-rows: auto auto;
  column-gap: 22px;
  row-gap: 24px;
  width: 100%;
  margin-top: 12px;
  align-items: start;
}

body.friend-virtual-battle .friend-virtual-battle-stage .friend-real-history-panel {
  grid-column: 1;
  grid-row: 1 / span 2;
  width: 100%;
  padding: 16px;
  min-height: 420px;
  max-height: 620px;
  overflow-y: auto;
  color: inherit;
  background: transparent;
  border: 1px solid rgba(40, 106, 150, 0.55);
}

body.friend-virtual-battle .friend-virtual-cube-row {
  grid-column: 2;
  grid-row: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 280px);
  gap: 22px;
  width: 100%;
  align-items: center;
}

body.friend-virtual-battle .friend-virtual-main-cube-slot {
  display: flex;
  min-width: 0;
  justify-content: center;
}

body.friend-virtual-battle .friend-virtual-opponent-slot {
  display: flex;
  width: 100%;
  min-width: 0;
  justify-content: center;
  align-items: center;
}

body.friend-virtual-battle .friend-virtual-roster-slot {
  grid-column: 2;
  grid-row: 2;
  width: 100%;
  margin-top: 0;
}

body.friend-virtual-battle .friend-real-room-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 20px;
}

body.friend-virtual-battle .friend-real-room-stats div {
  padding: 10px 6px;
  text-align: center;
  border: 1px solid rgba(120, 197, 239, 0.6);
  background: rgba(120, 197, 239, 0.1);
}

body.friend-virtual-battle .friend-real-room-stats dt {
  font-size: 13px;
  font-weight: 700;
}

body.friend-virtual-battle .friend-real-room-stats dd {
  margin: 4px 0 0;
  font-size: 20px;
  font-weight: 700;
}

body.friend-virtual-battle .friend-real-history-panel h3 {
  margin: 0 0 12px;
  text-align: center;
}

body.friend-virtual-battle .friend-real-history-panel ol {
  margin: 0;
  padding-left: 28px;
}

body.friend-virtual-battle .friend-real-history-panel li {
  margin: 0 0 10px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

body.friend-virtual-battle .friend-virtual-battle-stage .cube-area {
  display: flex;
  flex-direction: column;
  width: 100%;
  align-items: center;
  transform: none;
}

body.friend-virtual-battle .friend-virtual-battle-stage .battle-inspection-overlay {
  position: static;
  min-width: 160px;
  margin: 0 auto 10px;
  transform: none;
}

body.friend-virtual-battle .friend-virtual-battle-stage #cubeContainer {
  position: relative;
  width: min(100%, 620px);
  height: auto;
  aspect-ratio: 1;
  min-width: 0;
}

body.friend-virtual-battle .friend-virtual-battle-stage .opponent-cube-panel {
  position: static;
  width: 100%;
  max-width: 280px;
  margin: 0;
  transform: none;
}

body.friend-virtual-battle .multiplayer-roster {
  width: 100%;
  margin: 0 auto;
}

body.ranked-battle-mode .friend-virtual-cube-row,
body.ranked-battle-mode .friend-virtual-roster-slot {
  display: none;
}

body.ranked-battle-mode .friend-virtual-battle-stage {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr) minmax(220px, 280px);
  gap: 22px;
  width: 100%;
  margin-top: 12px;
  align-items: start;
}

body.ranked-battle-mode .friend-virtual-battle-stage .cube-area {
  grid-column: 2;
  display: flex;
  flex-direction: column;
  width: 100%;
  align-items: center;
  transform: none;
}

body.ranked-battle-mode .friend-virtual-battle-stage .battle-inspection-overlay {
  position: static;
  min-width: 160px;
  margin: 0 auto 10px;
  transform: none;
}

body.ranked-battle-mode .friend-virtual-battle-stage #cubeContainer {
  grid-column: 1;
  position: relative;
  width: min(100%, 620px);
  height: auto;
  aspect-ratio: 1;
  min-width: 0;
}

body.ranked-battle-mode .friend-virtual-battle-stage .opponent-cube-panel {
  position: static;
  grid-column: 3;
  width: 100%;
  max-width: 280px;
  margin: 0;
  transform: none;
}

body.ranked-battle-mode .friend-virtual-battle-stage .cube-area > .multiplayer-roster {
  position: static;
  width: 100%;
  max-width: 820px;
  margin: 14px auto 0;
  transform: none;
}

body.ranked-battle-mode .multiplayer-roster-toggle:disabled {
  opacity: 1;
  cursor: default;
}

.multiplayer-roster-identity {
  min-width: 0;
}

.multiplayer-roster-identity strong,
.multiplayer-roster-identity small {
  display: block;
  overflow-wrap: anywhere;
}

.multiplayer-roster-identity small {
  margin-top: 3px;
  font-size: 12px;
  font-weight: 700;
  opacity: 0.8;
}

@media (min-width: 901px) {
  html:has(body.ranked-battle-mode),
  body.ranked-battle-mode {
    height: 100%;
    overflow: hidden;
  }

  body.ranked-battle-mode .app {
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
  }

  body.ranked-battle-mode main {
    display: none;
  }

  body.ranked-battle-mode .battle-screen {
    display: grid;
    grid-template-rows: auto auto auto minmax(0, 1fr) auto auto auto auto;
    width: min(1280px, calc(100% - 24px));
    height: calc(100dvh - 12px);
    min-height: 0;
    margin: 6px auto;
    overflow: hidden;
  }

  body.ranked-battle-mode .battle-heading {
    grid-row: 1;
    min-height: 0;
    padding: 7px 10px;
  }

  body.ranked-battle-mode .battle-heading h2 {
    margin: 0 0 4px;
    font-size: 25px;
  }

  body.battle-mode.ranked-battle-mode .battle-scramble {
    grid-row: 2;
    min-height: 0;
    margin: 4px auto;
    padding: 3px 12px;
    font-size: clamp(20px, 2vw, 30px);
    line-height: 1.15;
  }

  body.ranked-battle-mode .ranked-time-limit {
    grid-row: 3;
    min-height: 18px;
    margin: 2px 0 4px;
    line-height: 1.1;
  }

  body.ranked-battle-mode .friend-virtual-battle-stage {
    grid-row: 4;
    display: grid;
    grid-template-columns: minmax(420px, 1fr) minmax(220px, 280px);
    gap: 24px;
    width: 100%;
    height: 100%;
    min-height: 0;
    margin: 0;
    align-items: start;
    justify-content: center;
    overflow: hidden;
  }

  body.ranked-battle-mode .friend-virtual-battle-stage .cube-area {
    grid-column: 1;
    display: flex;
    min-width: 0;
    min-height: 0;
    height: 100%;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    transform: none;
  }

  body.ranked-battle-mode .friend-virtual-battle-stage #cubeContainer {
    position: relative;
    flex: 0 0 auto;
    width: clamp(270px, 32vh, 350px);
    height: auto;
    max-width: 100%;
    max-height: 35vh;
    aspect-ratio: 1;
  }

  body.ranked-battle-mode .friend-virtual-battle-stage .opponent-cube-panel {
    position: static;
    grid-column: 2;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    width: 100%;
    height: clamp(250px, 32vh, 350px);
    max-width: 280px;
    max-height: 35vh;
    margin: 0;
    align-items: center;
    transform: none;
    overflow: hidden;
  }

  body.battle-mode.ranked-battle-mode .friend-virtual-battle-stage .cube-area > .multiplayer-roster {
    position: static;
    flex: 0 0 auto;
    width: min(100%, 760px);
    max-height: 142px;
    margin: 20px auto 0;
    padding: 8px;
    overflow: hidden;
    transform: none;
  }

  body.ranked-battle-mode .multiplayer-roster-toggle {
    min-height: 34px;
    margin-bottom: 4px;
    padding: 4px 8px;
    font-size: 20px;
  }

  body.ranked-battle-mode .multiplayer-roster-hint {
    margin: 0 0 5px;
    font-size: 12px;
  }

  body.battle-mode.ranked-battle-mode .multiplayer-roster-list {
    max-height: 76px;
    gap: 6px;
    overflow-y: auto;
  }

  body.battle-mode.ranked-battle-mode .multiplayer-roster-row {
    min-height: 52px;
    padding: 6px 9px;
    font-size: 14px;
  }

  body.battle-mode.ranked-battle-mode .battle-notice,
  body.battle-mode.ranked-battle-mode .battle-result {
    min-height: 16px;
    margin: 2px 0;
    font-size: 13px;
    line-height: 1.15;
  }

  body.ranked-battle-mode .battle-notice { grid-row: 5; }
  body.ranked-battle-mode .battle-result { grid-row: 6; }

  body.ranked-battle-mode .battle-result-badge {
    grid-row: 7;
    margin: 0;
    font-size: clamp(26px, 3vh, 38px);
    line-height: 1;
  }

  body.ranked-battle-mode .battle-rematch {
    grid-row: 8;
    width: min(100%, 620px);
    margin: 3px auto 0;
    padding: 6px 10px;
  }

  body.ranked-battle-mode .battle-rematch h2 {
    margin: 0 0 3px;
    font-size: 18px;
  }

  body.ranked-battle-mode .battle-rematch-actions {
    margin-top: 4px;
  }
}

#battleCubeSizeInput {
  width: 100%;
  margin-top: 10px;
}

body.friend-virtual-battle .multiplayer-roster:not(.expanded) .multiplayer-roster-list,
body.friend-virtual-battle .multiplayer-roster:not(.expanded) .multiplayer-roster-hint {
  display: none;
}

body.friend-virtual-battle .multiplayer-roster-toggle::after { content: none; }

/* Desktop Friend Virtual Battle: keep the complete competition surface in one viewport. */
@media (min-width: 901px) {
  html:has(body.friend-virtual-battle),
  body.friend-virtual-battle {
    height: 100%;
    overflow: hidden;
  }

  body.friend-virtual-battle .app {
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
  }

  body.friend-virtual-battle main {
    display: none;
  }

  body.friend-virtual-battle .battle-screen {
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr) auto auto auto;
    width: min(1500px, calc(100% - 24px));
    height: calc(100dvh - 12px);
    min-height: 0;
    margin: 6px auto;
    overflow: hidden;
  }

  body.friend-virtual-battle .battle-heading {
    min-height: 0;
    padding: 6px 10px 7px;
  }

  body.friend-virtual-battle .battle-heading h2 {
    margin: 0 0 4px;
    font-size: 24px;
  }

  body.battle-mode.friend-virtual-battle .battle-scramble {
    min-height: 0;
    margin: 5px auto;
    padding: 3px 12px;
    font-size: clamp(20px, 2vw, 30px);
    line-height: 1.15;
  }

  body.friend-virtual-battle .friend-virtual-battle-stage {
    display: grid;
    grid-template-columns: minmax(220px, 270px) minmax(360px, 1fr) minmax(220px, 280px);
    grid-template-rows: minmax(0, 1fr) auto;
    column-gap: 22px;
    row-gap: 20px;
    width: 100%;
    height: 100%;
    min-height: 0;
    margin-top: 0;
    align-items: stretch;
    overflow: hidden;
  }

  body.friend-virtual-battle .friend-virtual-cube-row {
    display: contents;
  }

  body.friend-virtual-battle .friend-virtual-main-cube-slot {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
    min-height: 0;
    align-items: center;
    justify-content: center;
    align-self: center;
  }

  body.friend-virtual-battle .friend-virtual-opponent-slot {
    grid-column: 3;
    grid-row: 1;
    min-width: 0;
    min-height: 0;
    align-items: flex-end;
    justify-content: center;
  }

  body.friend-virtual-battle .friend-virtual-roster-slot {
    grid-column: 2;
    grid-row: 2;
    align-self: end;
    width: 100%;
    min-width: 0;
    margin: 0;
  }

  body.friend-virtual-battle .friend-virtual-battle-stage #cubeContainer {
    width: clamp(645px, 75vh, 930px);
    height: auto;
    max-width: 100%;
    max-height: 75vh;
    aspect-ratio: 1;
  }

  body.friend-virtual-battle .friend-virtual-battle-stage .friend-real-history-panel {
    grid-column: 1;
    grid-row: 1 / span 2;
    min-height: 0;
    height: 100%;
    max-height: none;
    padding: 12px;
    overflow-y: auto;
  }

  body.friend-virtual-battle .friend-real-room-stats {
    margin-bottom: 12px;
  }

  body.friend-virtual-battle .friend-real-room-stats div {
    padding: 7px 4px;
  }

  body.friend-virtual-battle .friend-virtual-roster-slot {
    margin-top: 0;
  }

  body.battle-mode.friend-virtual-battle .multiplayer-roster {
    width: 100%;
    max-height: 132px;
    margin: 0;
    padding: 8px;
    overflow: hidden;
  }

  body.friend-virtual-battle .multiplayer-roster-toggle {
    min-height: 34px;
    margin-bottom: 4px;
    padding: 4px 8px;
    font-size: 20px;
  }

  body.friend-virtual-battle .multiplayer-roster-hint {
    margin: 0 0 5px;
    font-size: 12px;
  }

  body.battle-mode.friend-virtual-battle .multiplayer-roster-list {
    max-height: 72px;
    gap: 6px;
    padding-right: 6px;
    overflow-y: auto;
  }

  body.battle-mode.friend-virtual-battle .multiplayer-roster-row {
    min-height: 42px;
    padding: 7px 9px;
    font-size: 14px;
  }

  body.battle-mode.friend-virtual-battle .battle-notice,
  body.battle-mode.friend-virtual-battle .battle-result {
    min-height: 16px;
    margin: 2px 0;
    line-height: 1.15;
    font-size: 14px;
  }

  body.battle-mode.friend-virtual-battle .battle-result-badge {
    margin: 0;
    font-size: clamp(26px, 3vh, 38px);
    line-height: 1;
  }

  body.friend-virtual-battle .friend-virtual-battle-stage .opponent-cube-panel {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    width: 100%;
    height: clamp(270px, 34vh, 360px);
    max-width: 280px;
    max-height: 36vh;
    margin: 0;
    align-self: flex-end;
    align-items: center;
    overflow: hidden;
  }
}

@media (max-width: 900px) {
  body.friend-real-battle .friend-real-main-layout {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }
  body.friend-real-battle .friend-real-center-column {
    display: flex;
    order: 1;
    width: 100%;
  }
  body.friend-real-battle .friend-real-timer-panel { margin-top: 4px; }
  body.friend-real-battle .friend-real-timer-line {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
  }
  body.friend-real-battle .friend-real-next-overlay button {
    width: min(82%, 320px);
    min-height: 60px;
  }
  body.friend-real-battle .friend-real-timer {
    grid-column: 1;
    justify-self: center;
  }
  body.friend-real-battle .friend-real-edit-button {
    grid-column: 2;
    justify-self: start;
    margin-left: 0;
  }
  body.friend-real-battle .scramble-net-panel {
    order: 2;
    width: min(92vw, 320px);
    max-width: 320px;
    margin: 0 auto;
    align-self: center;
  }
  body.friend-real-battle .scramble-net-panel .cube-net { --net-sticker-size: clamp(10px, 3.2vw, 18px); }
  body.friend-real-battle .friend-real-history-panel { order: 3; width: 100%; min-height: 0; max-height: none; }
  body.friend-real-battle .friend-real-timer { font-size: clamp(64px, 20vw, 112px); }

  body.friend-virtual-battle .friend-virtual-battle-stage {
    display: flex;
    flex-direction: column;
    gap: 18px;
  }

  body.friend-virtual-battle .friend-virtual-cube-row {
    order: 1;
    display: flex;
    flex-direction: column;
    gap: 18px;
    width: 100%;
  }

  body.friend-virtual-battle .friend-virtual-main-cube-slot,
  body.friend-virtual-battle .friend-virtual-opponent-slot {
    width: 100%;
  }

  body.friend-virtual-battle .friend-virtual-roster-slot {
    order: 2;
    width: 100%;
  }

  body.friend-virtual-battle .friend-virtual-battle-stage .friend-real-history-panel {
    order: 3;
    width: 100%;
    min-height: 0;
    max-height: 420px;
  }

  body.friend-virtual-battle .friend-virtual-battle-stage #cubeContainer {
    width: min(94vw, 560px);
    height: auto;
  }

  body.friend-virtual-battle .friend-virtual-battle-stage .opponent-cube-panel {
    order: 2;
    align-self: center;
    width: min(92vw, 300px);
  }

  body.ranked-battle-mode .friend-virtual-battle-stage {
    display: flex;
    flex-direction: column;
  }

  body.ranked-battle-mode .friend-virtual-battle-stage .cube-area {
    order: 1;
    width: 100%;
  }

  body.ranked-battle-mode .friend-virtual-battle-stage #cubeContainer {
    width: min(94vw, 560px);
    height: auto;
  }

  body.ranked-battle-mode .friend-virtual-battle-stage .opponent-cube-panel {
    order: 2;
    align-self: center;
    width: min(92vw, 300px);
  }

  body.ranked-battle-mode .friend-virtual-battle-stage #cubeContainer > .battle-ready-button:not([hidden]) {
    position: absolute;
    top: 50%;
    left: 50%;
    width: min(78%, 360px);
    min-height: 68px;
    margin: 0;
    z-index: 5;
    transform: translate(-50%, -50%);
  }
}

@media (min-width: 901px) {
  body.friend-real-battle .battle-heading {
    align-items: flex-start;
    padding: 14px 18px;
    border-bottom: 3px solid #3977c9;
  }

  body.friend-real-battle .battle-mode-actions {
    align-items: center;
  }

  body.friend-real-battle .battle-scramble {
    margin-top: 8px;
  }
}

@media (max-width: 700px) {
  .friend-battle-settings-content {
    width: 100%;
    max-width: none;
    min-height: 100vh;
    max-height: 100vh;
    border: 0;
    border-radius: 0;
  }

  .battle-settings-button { min-height: 48px; }
}

.multiplayer-roster-hint {
  margin: -4px 0 12px;
  text-align: center;
  font-size: 14px;
}

.multiplayer-roster-hint[hidden] {
  display: none;
}

.multiplayer-roster-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  max-height: 240px;
  overflow-y: auto;
  padding-right: 8px;
}

.multiplayer-roster-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 64px;
  gap: 10px;
  align-items: center;
  padding: 9px 10px;
  background: rgba(255, 255, 255, 0.58);
  border-radius: 5px;
}

.multiplayer-roster-row.opponent-selectable {
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 120ms ease, background-color 120ms ease;
}

.multiplayer-roster-row.opponent-selectable:hover,
.multiplayer-roster-row.opponent-selectable:focus-visible {
  border-color: #3977c9;
  outline: none;
}

.multiplayer-roster-row.selected-opponent {
  border-color: #0f78b8;
  background: rgba(57, 119, 201, 0.2);
}

body.dark .multiplayer-roster-row.selected-opponent {
  border-color: #78c5ef;
  background: rgba(120, 197, 239, 0.2);
}

.multiplayer-roster-row time {
  text-align: right;
  font-family: "Courier New", monospace;
  font-weight: 700;
}

body.battle-mode .battle-scramble {
  max-width: 1200px;
  margin: 18px auto 12px;
  padding: 10px 16px;
  font-size: clamp(20px, 3vw, 40px);
  line-height: 1.35;
  overflow-wrap: anywhere;
}

body.battle-mode .battle-player-grid {
  display: none;
}

.scramble-net-panel {
  width: min(100%, 880px);
  margin: 10px auto 18px;
  padding: 14px;
  border: 2px solid rgba(17, 17, 17, 0.28);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.5);
}

.scramble-net-panel[hidden] {
  display: none;
}

.normal-real-scramble-net {
  width: min(92vw, 720px);
  margin: 0 auto 14px;
}

.normal-real-scramble-net .cube-net {
  --net-sticker-size: clamp(17px, 3vw, 34px);
}

body:not(.normal-real-cube) .normal-real-scramble-net,
body.battle-mode .normal-real-scramble-net,
body.real-timer-clean .normal-real-scramble-net {
  display: none !important;
}

.scramble-net-panel h3 {
  margin: 0 0 12px;
  text-align: center;
  font-size: 20px;
}

.cube-net {
  --net-sticker-size: clamp(20px, 4vw, 42px);
  display: grid;
  grid-template-columns: repeat(4, max-content);
  grid-template-rows: repeat(3, max-content);
  gap: 6px;
  justify-content: center;
  align-items: center;
}

.cube-net-face {
  position: relative;
}

.cube-net-face > strong {
  position: absolute;
  top: 3px;
  left: 5px;
  z-index: 1;
  color: #111;
  font-size: 11px;
  text-shadow: 0 0 2px #fff;
}

.cube-net-face-grid {
  display: grid;
  grid-template-columns: repeat(3, var(--net-sticker-size));
  grid-template-rows: repeat(3, var(--net-sticker-size));
  gap: 2px;
  padding: 3px;
  background: #111;
  border-radius: 4px;
}

.cube-net-face-grid span {
  border-radius: 2px;
}

.cube-net-face.face-u { grid-column: 2; grid-row: 1; }
.cube-net-face.face-l { grid-column: 1; grid-row: 2; }
.cube-net-face.face-f { grid-column: 2; grid-row: 2; }
.cube-net-face.face-r { grid-column: 3; grid-row: 2; }
.cube-net-face.face-b { grid-column: 4; grid-row: 2; }
.cube-net-face.face-d { grid-column: 2; grid-row: 3; }

body.battle-mode .multiplayer-roster {
  width: min(100%, 1100px);
  margin: 18px auto;
  padding: 18px;
}

body.battle-mode .multiplayer-roster h2 {
  margin-bottom: 14px;
  font-size: clamp(22px, 3vw, 30px);
}

body.battle-mode .multiplayer-roster-list {
  max-height: min(46vh, 520px);
  gap: 10px;
  padding-right: 10px;
}

body.battle-mode .multiplayer-roster-row {
  grid-template-columns: minmax(0, 1fr) auto minmax(76px, auto);
  min-height: 58px;
  padding: 12px 14px;
  font-size: clamp(16px, 2vw, 20px);
}

.real-room-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  align-items: baseline;
  justify-content: center;
  margin: 12px 0 18px;
}

.real-room-meta span {
  font-size: clamp(16px, 2vw, 22px);
  font-weight: 700;
}

.real-room-meta strong {
  padding: 5px 12px;
  border: 2px solid currentColor;
  border-radius: 6px;
  font-family: "Courier New", monospace;
  font-size: clamp(18px, 3vw, 32px);
  letter-spacing: 0;
  user-select: all;
}

.real-room-meta small {
  font-size: clamp(14px, 1.7vw, 18px);
}

.friend-real-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  width: min(100%, 1100px);
  margin: 0 auto 18px;
}

.friend-real-controls[hidden] {
  display: none;
}

.friend-real-controls button {
  width: min(100%, 420px);
  min-height: 64px;
  margin: 0;
  font-size: 22px;
  font-weight: 700;
}

.settings-toggle {
  display: flex;
  gap: 10px;
  align-items: center;
  font-weight: 700;
}

.settings-toggle input {
  width: 22px;
  height: 22px;
}

.normal-manual-entry-setting {
  margin-top: 12px;
}

.normal-manual-entry {
  display: flex;
  gap: 10px;
  width: min(92vw, 420px);
  margin: 12px auto 0;
}

.normal-manual-entry[hidden] {
  display: none;
}

body.battle-mode .normal-manual-entry {
  display: none;
}

.normal-manual-entry input {
  flex: 1;
  min-width: 0;
  margin: 0;
}

.normal-manual-entry button {
  width: auto;
  margin: 0;
  white-space: nowrap;
}

.settings-hint {
  margin: 8px 0 0;
  line-height: 1.45;
}

body.dark .scramble-net-panel {
  border-color: #6e98ad;
  background: rgba(10, 30, 42, 0.72);
}

.cube-mode-selector {
  display: flex;
  gap: 16px;
  margin: 8px 0 14px;
  padding: 12px;
  border: 1px solid rgba(17, 17, 17, 0.35);
  border-radius: 6px;
}

.cube-mode-selector legend {
  padding: 0 6px;
  font-weight: 700;
}

.cube-mode-selector label {
  display: flex;
  gap: 6px;
  align-items: center;
}

.real-cube-timer-button {
  min-width: 220px;
  min-height: 64px;
  margin: 16px auto 0;
  font-size: 22px;
  font-weight: 700;
}

.real-cube-instruction {
  max-width: 520px;
  margin: 12px auto 0;
  padding: 12px 16px;
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.4;
  background: rgba(255, 255, 255, 0.72);
  border: 2px solid #286a96;
  border-radius: 6px;
}

body.real-cube-battle #cubeContainer > canvas,
body.normal-real-cube #cubeContainer > canvas,
body.real-cube-battle #cubeContainer > canvas[hidden],
body.normal-real-cube #cubeContainer > canvas[hidden],
body.real-cube-battle .opponent-cube-panel,
body.real-cube-battle .move-input,
body.normal-real-cube .opponent-cube-panel,
body.normal-real-cube .move-input {
  display: none !important;
}

body.real-cube-battle #cubeContainer,
body.normal-real-cube #cubeContainer {
  width: min(92vw, 620px);
  height: 140px;
  min-height: 140px;
  background: transparent;
  pointer-events: none;
}

body.real-cube-battle .cube-area,
body.normal-real-cube .cube-area {
  justify-content: flex-start;
}

body.spectator-mode #battleReadyBtn,
body.spectator-mode #realCubeTimerBtn {
  display: none;
}

.key-bindings-settings {
  border: 2px solid #3977c9;
}

.settings-callout {
  margin: 0 0 12px;
  padding: 10px;
  background: rgba(57, 119, 201, 0.12);
  line-height: 1.45;
}

.reset-key-bindings {
  display: block;
  width: min(100%, 280px);
  margin: 16px auto 0;
}

.beginner-tip-content {
  max-width: 460px;
  text-align: center;
}

.beginner-tip-content h2 {
  margin-top: 0;
}

.beginner-tip-content button {
  width: min(100%, 240px);
  margin-top: 10px;
}

body.dark .multiplayer-roster {
  border-color: #78c5ef;
}

body.dark .multiplayer-roster-row,
body.dark .settings-callout {
  background: rgba(255, 255, 255, 0.1);
}

body.dark .real-cube-instruction {
  color: #f5f5f5;
  background: rgba(16, 33, 44, 0.9);
  border-color: #78c5ef;
}

body.dark .key-bindings-settings {
  border-color: #78c5ef;
}

.battle-ready-button {
  display: none;
  position: absolute;
  z-index: 4;
  top: 50%;
  left: 50%;
  width: min(74%, 360px);
  min-height: 64px;
  margin: 0;
  border: 2px solid #0d4c76;
  background: #0f78b8;
  color: #fff;
  font-size: 20px;
  font-weight: bold;
  transform: translate(-50%, -50%);
}

body.battle-mode .battle-ready-button:not([hidden]) {
  display: block;
}

body.battle-mode.battle-locked #cubeContainer {
  opacity: 0.35;
}

body.battle-mode #cubeContainer.ready-waiting {
  opacity: 0.35;
}

.battle-inspection-overlay {
  position: absolute;
  z-index: 3;
  top: 12%;
  left: 50%;
  min-width: 160px;
  padding: 12px 18px;
  border-radius: 8px;
  background: rgba(8, 50, 76, 0.88);
  color: #fff !important;
  text-align: center;
  transform: translateX(-50%);
  pointer-events: none;
}

.battle-inspection-overlay[hidden] {
  display: none;
}

#battleInspectionLabel {
  color: #f5f7fa !important;
  font-size: 16px;
  font-weight: bold;
}

#battleInspectionCount {
  color: #fff !important;
  font-family: "Courier New", monospace;
  font-size: 52px;
  font-weight: bold;
}

body.inspection-hold-red #battleInspectionCount {
  color: #ff5b52 !important;
}

body.inspection-hold-green #battleInspectionCount {
  color: #45df78 !important;
}

body.real-timer-clean .battle-inspection-overlay {
  position: fixed !important;
  z-index: 10001 !important;
  left: 50% !important;
  opacity: 1 !important;
  filter: none !important;
  isolation: isolate;
  border: 2px solid rgba(255, 255, 255, 0.58);
  background: rgba(5, 16, 24, 0.94) !important;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.42);
}

body.real-timer-clean #battleInspectionLabel,
body.real-timer-clean #battleInspectionCount {
  position: relative;
  z-index: 10002;
  opacity: 1 !important;
  text-shadow: 0 2px 8px #000, 0 0 2px #000;
}

body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .cube-area {
  display: none;
}

@media (min-width: 901px) {
  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) main {
    display: block;
    min-height: calc(100vh - 170px);
  }

  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .left-panel {
    top: 8px;
  }

  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .panel {
    display: flex;
    flex-direction: column;
    top: 8px;
    right: 48px;
    bottom: auto;
    width: clamp(280px, 20vw, 360px);
    max-height: calc(100vh - 195px);
    overflow-y: auto;
  }

  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .panel .timer {
    position: static;
    z-index: auto;
    top: auto;
    left: auto;
    margin: 0;
    color: inherit;
    font-size: clamp(84px, 11vw, 164px);
    line-height: 1;
    transform: none;
    pointer-events: auto;
    touch-action: none;
  }

  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .real-cube-instruction,
  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .real-cube-timer-button {
    position: static;
    z-index: auto;
    left: auto;
    transform: none;
  }

  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .real-cube-instruction { top: auto; }
  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .real-cube-timer-button { top: auto; }

  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .normal-real-scramble-net {
    position: static;
    z-index: auto;
    right: auto;
    bottom: auto;
    width: clamp(250px, 18vw, 310px);
    margin: 0;
    padding: 10px;
  }

  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .normal-real-history-column {
    display: contents;
  }

  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .normal-real-scramble-net .cube-net {
    --net-sticker-size: clamp(10px, 1.25vw, 19px);
    gap: 3px;
  }

  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .normal-real-scramble-net h3 {
    margin-bottom: 8px;
    font-size: 16px;
  }
}

/* Solo Real Cube: one compact, scrollable center flow. */
body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .timer,
body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .cube-area,
body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .real-cube-instruction,
body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .real-cube-timer-button,
body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .normal-real-scramble-net {
  position: static !important;
  inset: auto !important;
  transform: none !important;
}

body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .cube-area {
  height: auto !important;
  min-height: 0 !important;
  align-content: start;
  align-items: center;
  gap: 8px;
}

body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .real-cube-instruction {
  margin: 2px auto 0 !important;
  padding: 0 !important;
  border: 0 !important;
  color: inherit;
  background: transparent !important;
  box-shadow: none !important;
  font-size: clamp(16px, 1.6vw, 19px);
  font-weight: 500;
}

body.dark.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .real-cube-instruction {
  color: #d8dde1;
}

body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .real-cube-timer-button {
  margin: 2px auto 0 !important;
}

body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .normal-real-scramble-net {
  margin: 8px auto 0 !important;
}

@media (min-width: 1101px) {
  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) main {
    grid-template-rows: max-content max-content;
  }

  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .timer {
    grid-column: 2;
    grid-row: 1;
    align-self: end;
    margin: 6px 0 0 !important;
  }

  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .cube-area {
    grid-column: 2;
    grid-row: 2;
    display: flex !important;
    flex-direction: column;
  }
}

@media (max-width: 1100px) {
  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .timer {
    order: 1;
    margin: 2px auto 0 !important;
  }

  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .cube-area {
    order: 2;
    display: flex !important;
    flex-direction: column;
  }
}

@media (max-width: 900px) {
  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .panel {
    display: flex;
    flex-direction: column;
  }

  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .normal-real-history-column {
    display: contents;
  }

  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .timer {
    order: 1;
    font-size: clamp(64px, 20vw, 104px);
    touch-action: none;
  }

  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .real-cube-instruction { order: 2; }
  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .real-cube-timer-button { order: 3; }

  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .normal-real-scramble-net {
    position: static;
    width: min(94vw, 520px);
    margin: 12px auto;
    order: 4;
  }

  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .tps-display { order: 5; }
  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .moves-display { order: 6; }
  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .stats { order: 7; }
  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .normal-real-history-column > .buttons { order: 8; }
  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .last-move { order: 9; }
  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .normal-real-history-column > h2,
  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .normal-real-history-column > ul { order: 10; }

  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .normal-real-scramble-net .cube-net {
    --net-sticker-size: clamp(12px, 3vw, 24px);
  }
}

.battle-ready-button:disabled {
  cursor: default;
  opacity: 1;
  background: #4a6474;
  border-color: #4a6474;
}

.secondary-action {
  background: #1e5f8b;
}

.battle-scramble {
  text-align: center;
  min-height: 24px;
  font-size: 16px;
  word-break: break-word;
}

.battle-notice,
.battle-result {
  text-align: center;
  font-weight: bold;
  min-height: 24px;
  margin: 10px 0;
}

.battle-result-badge {
  min-height: 0;
  text-align: center;
  font-size: 42px;
  font-weight: bold;
  letter-spacing: 0;
}

.battle-result-badge.winner {
  color: #147a3f;
}

.battle-result-badge.loser {
  color: #b33131;
}

.battle-rematch {
  max-width: 520px;
  margin: 18px auto 0;
  padding: 16px;
  border: 2px solid #1e5f8b;
  border-radius: 8px;
  text-align: center;
  background: rgba(255, 255, 255, 0.76);
  font-weight: bold;
}

.battle-rematch h2 {
  margin: 0 0 10px;
  font-size: 24px;
}

.battle-rematch > div:not(.battle-rematch-actions) {
  margin: 5px 0;
}

.battle-rematch-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 14px;
}

.battle-notice {
  color: #164c70;
}

.battle-player-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.battle-player-card {
  border: 2px solid #226a93;
  border-radius: 8px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.76);
  min-height: 240px;
}

.battle-player-card.opponent {
  border-color: #8a4e25;
}

.battle-player-title {
  font-size: 14px;
  font-weight: bold;
  text-transform: uppercase;
  color: #1e5f8b;
}

.opponent .battle-player-title {
  color: #8a4e25;
}

.battle-player-name {
  font-size: 24px;
  font-weight: bold;
  overflow-wrap: anywhere;
}

.battle-opponent-rating {
  min-height: 20px;
  margin-top: 4px;
  font-size: 14px;
  font-weight: bold;
  opacity: 0.82;
}

.battle-player-state {
  display: inline-block;
  margin: 8px 0;
  padding: 4px 8px;
  border-radius: 4px;
  background: #1e5f8b;
  color: #fff;
  font-size: 12px;
  font-weight: bold;
}

.opponent .battle-player-state {
  background: #8a4e25;
}

.battle-player-timer {
  font-family: "Courier New", monospace;
  font-size: 40px;
  font-weight: bold;
}

.battle-player-card dl {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 10px 0;
}

.battle-player-card dl div {
  border-left: 3px solid #a8d8f1;
  padding-left: 7px;
}

.battle-player-card dt {
  font-size: 12px;
  opacity: 0.75;
}

.battle-player-card dd {
  margin: 2px 0 0;
  font-weight: bold;
}

.battle-move-title {
  font-size: 14px;
  font-weight: bold;
}

.battle-move-log {
  min-height: 42px;
  margin-top: 5px;
  padding: 7px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.08);
  font-family: "Courier New", monospace;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.ranking-type-tabs,
.ranking-tabs {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
}

.ranking-type-tabs {
  grid-template-columns: repeat(4, 1fr);
}

.ranking-tabs {
  grid-template-columns: repeat(4, 1fr);
}

.ranking-type-tab,
.ranking-tab {
  border-radius: 8px;
  padding: 9px 4px;
  font-size: 13px;
}

.ranking-type-tab.active,
.ranking-tab.active {
  background: #3a7cff;
  color: white;
}

#onlineRankingList {
  padding-left: 24px;
  max-height: 180px;
  overflow-y: auto;
  font-size: 14px;
}

.battle-rating-panel {
  margin-top: 18px;
}

#battleRatingList {
  max-height: 220px;
  margin: 0;
  padding-left: 24px;
  overflow-y: auto;
}

#battleRatingList li {
  margin: 4px 0;
  font-size: 14px;
}

#scrambleHistoryList {
  padding: 0 10px 0 24px;
  max-height: min(22vh, 160px);
  overflow-y: auto;
  font-size: 13px;
  margin: 0;
  scrollbar-gutter: stable;
}

body.dark {
  --bg: #0b202b;
  --surface: rgba(16, 39, 52, 0.94);
  --surface-2: rgba(28, 61, 78, 0.82);
  --border: #315b70;
  --text: #f5f5f5;
  --text-muted: rgba(245, 245, 245, 0.68);
  --primary: #65c7f7;
  --primary-hover: #8ad8ff;
  --danger: #b74455;
  --danger-hover: #d05a6a;
  background-color: var(--bg);
  color: var(--text);
}

body.custom-background,
body.dark.custom-background {
  background-image: var(--custom-background-image);
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
  background-attachment: fixed;
}

body.dark .panel {
  background: rgba(30, 30, 30, 0.92);
  color: #f5f5f5;
}

body.dark .left-panel {
  background: rgba(30, 30, 30, 0.92);
  color: #f5f5f5;
}

body.dark button {
  background: #f5f5f5;
  color: #111;
}

body.dark .primary-action,
body.dark #createRoomBtn,
body.dark #joinRoomBtn,
body.dark #randomBattleBtn,
body.dark #battleReadyBtn,
body.dark #openBattleBtn {
  background: #65c7f7;
  color: #082231;
}

body.dark .secondary-action,
body.dark .header-action.secondary-action,
body.dark #copyRoomIdBtn,
body.dark #copyRoomUrlBtn,
body.dark #openSettingsBtn,
body.dark #openRankingBtn,
body.dark #howToPlayBtn,
body.dark #cancelMatchBtn,
body.dark .battle-choice-tab {
  border-color: rgba(120, 197, 239, 0.34);
  background: rgba(16, 33, 44, 0.86);
  color: #f5f5f5;
}

body.dark .danger-action,
body.dark #clearTimesBtn,
body.dark #friendRealDnfBtn,
body.dark #friendRealRemoveBtn {
  background: #b74455;
  color: #fff;
}

body.dark .friend-battle-card,
body.dark .friend-room-share,
body.dark .stats div,
body.dark .battle-status {
  border-color: rgba(120, 197, 239, 0.22);
  background: rgba(16, 33, 44, 0.72);
}

body.dark .theme-toggle {
  background: #444;
  color: white;
}

body.dark #playerNameInput,
body.dark #roomIdInput,
body.dark #roomUrlOutput {
  border-color: #f5f5f5;
  background: #222;
  color: #f5f5f5;
}

body.dark .move-input {
  border-color: #f5f5f5;
  background: #222;
  color: #f5f5f5;
}

body.dark .modal-content {
  border-color: #78c5ef;
  background: #183747;
  color: #f5f5f5;
}

body.dark #animationSpeedSelect,
body.dark #normalTimerModeSelect {
  border-color: #f5f5f5;
  background: #10212c;
  color: #f5f5f5;
}

body.dark #backgroundImageInput {
  color: #f5f5f5;
}

body.dark .key-binding-row {
  border-color: #4d7184;
  background: #10212c;
}

body.dark .key-binding-key {
  background: #29475a;
}

body.dark .modal-heading {
  border-color: #4d7184;
}

body.dark .key-map span {
  border-color: #4d7184;
  background: #10212c;
}

body.dark .profile-grid div {
  border-color: #78c5ef;
}

body.dark .ranking-type-tab.active,
body.dark .ranking-tab.active {
  background: #78a6ff;
  color: #111;
}

body.dark .battle-choice-tab.active {
  background: #78c5ef;
  color: #111;
}

body.dark .battle-result-badge.winner {
  color: #8ee6ad;
}

body.dark .battle-result-badge.loser {
  color: #ffaaa3;
}

body.dark .battle-ready-button {
  border-color: #9ddcff;
  background: #2c91cf;
  color: #111;
}

body.dark .battle-ready-button:disabled {
  background: #4b6573;
  border-color: #4b6573;
  color: #f5f5f5;
}

body.dark .battle-rematch {
  border-color: #78c5ef;
  background: #183747;
}

body.dark.battle-mode {
  background-color: #10212c;
}

body.dark .battle-heading {
  border-color: #78c5ef;
}

body.dark .battle-player-card {
  background: #183747;
  border-color: #78c5ef;
}

body.dark .battle-player-card.opponent {
  border-color: #e9ae82;
}

body.dark.battle-mode .opponent-cube-panel {
  border-color: #e9ae82;
  background: #183747;
}

body.dark .battle-player-title,
body.dark .battle-notice {
  color: #a8dfff;
}

body.dark .ranked-time-limit {
  color: #a8dfff;
}

body.dark .opponent .battle-player-title {
  color: #ffd0a9;
}

body.dark .battle-move-log {
  background: rgba(255, 255, 255, 0.1);
}

body.dark .solve-details {
  border-color: #78c5ef;
  background: rgba(255, 255, 255, 0.08);
}

body.solving header,
body.solving footer,
body.solving .left-panel,
body.solving .panel .theme-toggle,
body.solving .panel .stats,
body.solving .panel .last-move,
body.solving .panel h2,
body.solving .panel ul {
  display: none;
}

body.solving:not(.battle-mode) .panel .buttons {
  display: flex;
  margin-top: 12px;
}

body.solving:not(.battle-mode) .panel #scrambleBtn,
body.solving:not(.battle-mode) .panel #clearTimesBtn {
  display: none;
}

body.solving:not(.battle-mode) .panel #resetBtn {
  display: block;
  background: #8f2929;
}

body.dark.solving:not(.battle-mode) .panel #resetBtn {
  background: #f3a19d;
  color: #111;
}

body.solving main {
  min-height: 100vh;
}

body.solving .cube-area {
  transform: none;
}

body.solving .panel {
  position: fixed;
  top: 24px;
  left: auto;
  right: 48px;
  width: auto;
  max-height: none;
  overflow: visible;
  padding: 0;
  transform: none;
}

body.solving .timer {
  margin: 0;
  font-size: 64px;
}

@media (max-width: 900px) {
  body.real-timer-clean {
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    touch-action: none;
    overscroll-behavior: none;
  }

  body.real-timer-clean main,
  body.real-timer-clean main * {
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    touch-action: none;
  }

  body.real-timer-clean header,
  body.real-timer-clean .left-panel,
  body.real-timer-clean .battle-screen,
  body.real-timer-clean footer,
  body.real-timer-clean .opponent-cube-panel,
  body.real-timer-clean .move-input,
  body.real-timer-clean .real-cube-instruction,
  body.real-timer-clean .real-cube-timer-button {
    display: none !important;
  }

  body.real-timer-clean main {
    position: fixed;
    z-index: 100;
    inset: 0;
    display: block;
    min-height: 100dvh;
    padding: 0;
    background: inherit;
    touch-action: none;
  }

  body.real-timer-clean .cube-area {
    position: absolute;
    z-index: 1;
    inset: 0;
    width: 100%;
    height: 100%;
    transform: none;
    pointer-events: none;
  }

  body.real-timer-clean #cubeContainer {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    pointer-events: none;
  }

  body.real-timer-clean .battle-inspection-overlay {
    top: 22%;
    min-width: 190px;
  }

  body.real-timer-clean #battleInspectionCount {
    font-size: 72px;
  }

  body.real-timer-clean .panel {
    position: absolute;
    z-index: 2;
    inset: 0;
    display: flex;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    pointer-events: none;
  }

  body.real-timer-clean .panel > * {
    display: none !important;
  }

  body.real-timer-clean.real-timer-solving .panel .timer {
    display: block !important;
    margin: 0;
    font-size: clamp(64px, 20vw, 120px);
  }

  body.real-timer-clean .panel .buttons {
    position: absolute;
    right: 18px;
    bottom: 18px;
    display: block !important;
    width: auto;
    margin: 0;
    pointer-events: auto;
  }

  body.real-timer-clean .panel .buttons > * {
    display: none !important;
  }

  body.real-timer-clean .panel #resetBtn {
    display: block !important;
    width: auto;
    min-width: 112px;
    margin: 0;
    padding: 14px 20px;
    background: #8f2929;
  }

  header {
    padding: 10px;
  }

  h1 {
    margin-bottom: 14px;
    font-size: 28px;
  }

  .scramble {
    font-size: clamp(20px, 6vw, 28px);
    padding: 6px 12px;
  }

  main {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px;
  }

  .cube-area {
    transform: none;
  }

  .left-panel {
    position: static;
    width: 92vw;
    max-height: none;
    overflow-y: visible;
    padding: 18px 20px;
    margin: 12px auto 0;
    order: 2;
  }

  #cubeContainer {
    width: min(96vw, 55vh);
    height: min(96vw, 55vh);
    max-width: 520px;
    max-height: 520px;
  }

  .move-input {
    display: block;
  }

  .panel {
    position: static;
    transform: none;
    width: 92vw;
    margin: 12px auto 24px;
    max-height: none;
    overflow-y: visible;
    padding: 18px 20px;
  }

  .timer {
    font-size: 44px;
  }

  body.solving .left-panel {
    display: none;
  }

  body.solving .move-input {
    display: block;
  }

  body.solving .panel {
    position: static;
    width: auto;
    margin: 0 auto 12px;
  }

  body.solving .timer {
    font-size: 52px;
  }

  body.battle-mode .battle-screen {
    width: calc(100% - 16px);
    margin-top: 8px;
  }

  body.battle-mode #cubeContainer {
    width: min(96vw, 55vh);
    height: min(96vw, 55vh);
  }

  body.battle-mode .opponent-cube-panel {
    position: static;
    width: min(92vw, 300px);
    margin: 14px auto 0;
    transform: none;
  }

  .battle-heading,
  .battle-mode-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .battle-player-grid {
    grid-template-columns: 1fr;
  }

  .battle-player-card {
    min-height: 0;
  }

  .battle-result-badge {
    font-size: 34px;
  }

  .battle-ready-button {
    width: min(76vw, 420px);
    min-height: 68px;
  }

  .battle-rematch-actions {
    grid-template-columns: 1fr;
  }

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

  .header-actions {
    gap: 6px;
  }

  .header-action {
    flex: 1 1 42%;
    min-height: 42px;
  }

  .feature-modal {
    padding: 0;
    place-items: stretch;
  }

  .feature-content {
    width: 100%;
    max-height: 100vh;
    min-height: 100vh;
    border: 0;
    border-radius: 0;
    padding: 18px 16px 32px;
  }

  .feature-content .modal-close {
    min-width: 84px;
    min-height: 44px;
  }

  .key-bindings-list {
    grid-template-columns: 1fr;
  }

  .ranking-type-tabs {
    grid-template-columns: repeat(2, 1fr);
  }

  .key-binding-change {
    display: block;
  }

  .multiplayer-roster-list {
    grid-template-columns: 1fr;
  }

  .cube-mode-selector {
    flex-direction: column;
  }

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

  footer {
    font-size: 12px;
    padding: 8px;
  }

  .info-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .info-content {
    margin: 12px auto 20px;
    padding: 18px;
  }
}

/* Final solo Real Cube layout overrides. */
body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .panel {
  display: contents !important;
}

body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .timer,
body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .cube-area,
body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .real-cube-instruction,
body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .real-cube-timer-button,
body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .normal-real-scramble-net {
  position: static !important;
  inset: auto !important;
  transform: none !important;
}

body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .real-cube-instruction {
  width: auto;
  max-width: min(92vw, 520px);
  min-height: 0;
  margin: 6px auto 0 !important;
  padding: 0;
  border: 0;
  border-radius: 0;
  color: inherit;
  background: transparent;
  font-size: clamp(16px, 1.6vw, 19px);
  font-weight: 500;
  line-height: 1.35;
  box-shadow: none;
}

body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) #cubeContainer {
  display: none !important;
  width: 0;
  height: 0;
  min-height: 0;
}

body.dark.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .real-cube-instruction {
  color: #d8dde1;
  background: transparent;
  border: 0;
}

body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) #scrambleBtn,
body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) #resetBtn {
  display: none !important;
}

@media (min-width: 1101px) {
  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) main {
    display: grid;
    grid-template-columns: clamp(280px, 22vw, 380px) minmax(420px, 1fr) clamp(300px, 22vw, 380px);
    grid-template-rows: auto 1fr;
    gap: 18px 28px;
    align-items: start;
    min-height: calc(100vh - 170px);
    padding: 8px 48px 24px;
  }

  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .left-panel {
    position: static;
    grid-column: 1;
    grid-row: 1 / span 2;
    width: 100%;
    max-height: calc(100vh - 205px);
  }

  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .timer {
    position: static;
    grid-column: 2;
    grid-row: 1;
    align-self: end;
    margin: 12px 0 0;
    font-size: clamp(84px, 10vw, 156px);
    line-height: 1;
    transform: none;
    pointer-events: auto;
    touch-action: none;
  }

  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .cube-area {
    position: static;
    grid-column: 2;
    grid-row: 2;
    display: flex;
    width: 100%;
    transform: none;
  }

  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .real-cube-instruction,
  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .real-cube-timer-button,
  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .normal-real-scramble-net {
    position: static;
    inset: auto;
    transform: none;
  }

  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .real-cube-instruction { margin: 8px auto 0; }
  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .real-cube-timer-button { margin: 8px auto 0; }

  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .normal-real-scramble-net {
    width: min(100%, 420px);
    margin: 14px auto 0;
    padding: 10px;
  }

  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .normal-real-scramble-net .cube-net {
    --net-sticker-size: clamp(12px, 1.45vw, 22px);
  }

  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .normal-real-history-column {
    display: block;
    grid-column: 3;
    grid-row: 1 / span 2;
    width: 100%;
    max-height: calc(100vh - 205px);
    overflow-y: auto;
    padding: 18px 20px;
    scrollbar-gutter: stable;
  }

  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) #timeList {
    min-height: 132px;
    max-height: 220px;
  }

  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) #scrambleHistoryList {
    min-height: 108px;
    max-height: 180px;
  }
}

@media (max-width: 1100px) {
  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) main {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 10px 12px 24px;
  }

  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .timer {
    position: static;
    order: 1;
    width: 94vw;
    margin: 4px auto 0;
    font-size: clamp(64px, 20vw, 108px);
    transform: none;
    pointer-events: auto;
    touch-action: none;
  }

  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .cube-area {
    position: static;
    order: 2;
    display: flex;
    width: 94vw;
    transform: none;
  }

  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .real-cube-instruction,
  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .real-cube-timer-button,
  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .normal-real-scramble-net {
    position: static;
    inset: auto;
    transform: none;
  }

  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .normal-real-scramble-net {
    width: min(94vw, 520px);
    margin: 12px auto 0;
  }

  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .normal-real-history-column {
    display: block;
    order: 3;
    width: 94vw;
    max-height: none;
    overflow: visible;
    padding: 18px 20px;
  }

  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) .left-panel {
    position: static;
    order: 4;
    width: 94vw;
    max-height: none;
  }

  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) #timeList,
  body.normal-real-cube:not(.battle-mode):not(.real-timer-clean) #scrambleHistoryList {
    min-height: 72px;
    max-height: 240px;
  }
}
