@font-face {
  font-family: 'Lato';
  font-style: normal;
  font-weight: 400;
  src: local('Lato Regular'), local('Lato-Regular'), url(https://fonts.gstatic.com/s/lato/v11/MDadn8DQ_3oT6kvnUq_2r_esZW2xOQ-xsNqO47m55DA.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000;
}
@font-face {
  font-family: 'Source Sans Pro';
  font-style: normal;
  font-weight: 400;
  src: local('Source Sans Pro'), local('SourceSansPro-Regular'), url(https://fonts.gstatic.com/s/sourcesanspro/v9/ODelI1aHBYDBqgeIAH2zlJbPFduIYtoLzwST68uhz_Y.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000;
}
@font-face {
  font-family: 'Source Sans Pro';
  font-style: normal;
  font-weight: 900;
  src: local('Source Sans Pro Black'), local('SourceSansPro-Black'), url(https://fonts.gstatic.com/s/sourcesanspro/v9/toadOcfmlt9b38dHJxOBGIq-Fb0zf838trI74uojZQY.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000;
}
@font-face {
  font-family: 'FontAwesome';
  src: url('../fonts/fontawesome-webfont.eot?v=3.0.1');
  src: url('../fonts/fontawesome-webfont.eot?#iefix&v=3.0.1') format('embedded-opentype'),
    url('../fonts/fontawesome-webfont.woff?v=3.0.1') format('woff'),
    url('../fonts/fontawesome-webfont.ttf?v=3.0.1') format('truetype');
  font-weight: normal;
  font-style: normal;
}
/* General */
html {
  font-size: 1em;
}
body {
  font: 1em 'Source Sans Pro';
  margin: 0;
  background: #000;
  background-size: cover;
  color: #fff;
}
body.gameplay-active {
  overflow: hidden;
}
a {
  color: #fff;
  text-decoration: none;
}
table {
  border-collapse: collapse;
  border-spacing: 0;
}
th {
  padding: 0;
  font-weight: normal;
}
td {
  padding: 0;
}

/* Header */
h1 {
  color: #fff;
  font-size: 2rem;
  margin: 0.65em 0;
}
.subtitle {
  color: #fff;
  font-size: 0.9rem;
  font-weight: 200;
  letter-spacing: 0.2em;
  margin: -1.8em 0 1em 0;
  text-align: center;
  opacity: 0.7;
}
h3 {
  margin: 0;
  text-transform: uppercase;
  font-weight: normal;
  text-align: center;
}
nav > ul {
  margin: 0;
  padding: 0;
  list-style: none;
}
.button,
nav li {
  display: block;
}
.button,
nav a {
  font: 1.25rem 'Lato';
  display: inline-block;
  width: 50%;
  color: #fff;
  border: 2px solid #fff;
  cursor: pointer;
  border-radius: 5px;
  padding: 0.3rem 0.6rem 0.4rem;
  margin: 0.5em;
  background: #000;
  transition: all 0.15s ease;
}
/* Exclude logo from nav a styles - reset nav a properties but allow #logo-text properties */
nav a#logo-text {
  font: unset;
  width: unset;
  color: unset;
  border: unset;
  cursor: unset;
  border-radius: unset;
  padding: unset;
  margin: unset;
  background: unset;
  transition: unset;
}
nav a.menu-focused,
.button.menu-focused {
  border-color: #4da6ff;
  background: rgba(77, 166, 255, 0.15);
  box-shadow: 0 0 12px rgba(77, 166, 255, 0.6);
  transform: scale(1.02);
}
/* Prevent logo from getting menu-focused styles */
nav a#logo-text.menu-focused,
#menu-main h1 a#logo-text.menu-focused,
#menu-main a#logo-text {
  border: none !important;
  box-shadow: none !important;
  transform: none !important;
  border-color: transparent !important;
  border-radius: 0 !important;
}
nav a.menu-item-with-thumbnail.menu-focused {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 0 16px rgba(77, 166, 255, 0.7), 0 4px 12px rgba(77, 166, 255, 0.3);
}
nav a.menu-item-with-thumbnail.menu-focused .menu-item-thumbnail {
  border-color: #4da6ff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6),
              0 0 20px rgba(77, 166, 255, 0.5);
}
nav a.disabled {
  color: #555;
  border-color: #555;
  cursor: not-allowed;
  pointer-events: none;
  opacity: 0.5;
}
nav a.menu-item-with-thumbnail.disabled .menu-item-thumbnail {
  border-color: rgba(85, 85, 85, 0.3);
  box-shadow: none;
  filter: grayscale(50%) brightness(0.7);
}
/* Menu item with thumbnail styling */
nav a.menu-item-with-thumbnail {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.7rem;
  transition: all 0.2s ease;
  width: calc(100% - 1em);
  box-sizing: border-box;
  margin-left: auto;
  margin-right: auto;
}
nav a.menu-item-with-thumbnail:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(77, 166, 255, 0.3);
}
nav a.menu-item-with-thumbnail .menu-item-thumbnail {
  flex-shrink: 0;
  width: 110px;
  height: 75px;
  border-radius: 6px;
  border: 2px solid rgba(77, 166, 255, 0.4);
  object-fit: contain;
  background: rgba(0, 0, 0, 0.5);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4),
              0 0 12px rgba(77, 166, 255, 0.15);
  transition: all 0.2s ease;
}
nav a.menu-item-with-thumbnail:hover .menu-item-thumbnail {
  border-color: rgba(77, 166, 255, 0.7);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6),
              0 0 20px rgba(77, 166, 255, 0.35);
  transform: scale(1.05);
}
nav a.menu-item-with-thumbnail .menu-item-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  position: relative;
}
nav a.menu-item-with-thumbnail .menu-item-content > span {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 1.3rem;
  font-weight: 500;
}
nav a.menu-item-with-thumbnail .skip-btn {
  position: absolute;
  right: 0;
  bottom: 0;
}
nav a.menu-item-with-thumbnail .progress-container {
  width: calc(100% - 4.5rem);
}
/* Progress bar container inside menu buttons */
.progress-container {
  position: relative;
  width: 100%;
  height: 18px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
  margin-top: 0.4rem;
  overflow: hidden;
}
/* Container for progress bar and skip button */
nav a:has(.skip-btn) {
  position: relative;
}
/* Make progress bar narrower when skip button is present */
nav a:has(.skip-btn) .progress-container {
  width: calc(100% - 4.5rem);
  margin-right: 0.5rem;
}
/* Progress bar fill */
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #4da6ee 0%, #3397d9 100%);
  border-radius: 2px;
  transition: width 0.3s ease-in-out;
}
/* Progress percentage text - overlayed and centered */
.progress-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.7rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
  pointer-events: none;
  z-index: 1;
}
/* Show green gradient when complete */
.progress-bar.complete {
  background: linear-gradient(90deg, #78a82e 0%, #5d8a0f 100%);
}
/* Enhanced text visibility on complete progress bars */
.progress-bar.complete + .progress-text {
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.95), 0 0 8px rgba(0, 0, 0, 0.7);
  font-weight: 700;
}
/* Disabled button progress styling */
nav a.disabled .progress-container {
  background: rgba(85, 85, 85, 0.15);
}
nav a.disabled .progress-bar {
  background: rgba(85, 85, 85, 0.5);
}
nav a.disabled .progress-text {
  color: rgba(85, 85, 85, 0.8);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}
/* Skip button styling */
.skip-btn {
  position: absolute;
  right: 0;
  bottom: 0.4rem;
  padding: 0.2rem 0.6rem;
  font-size: 0.7rem;
  font-family: 'Lato';
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 3px;
  color: rgba(255, 255, 255, 0.8);
  cursor: pointer;
  transition: all 0.2s ease;
  height: 18px;
  line-height: 1;
}
.skip-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.5);
  color: #fff;
}
.skip-btn.skipped {
  background: rgba(255, 165, 0, 0.3);
  border-color: rgba(255, 165, 0, 0.6);
  color: rgba(255, 200, 100, 1);
}
.skip-btn.skipped:hover {
  background: rgba(255, 165, 0, 0.4);
  border-color: rgba(255, 165, 0, 0.8);
  color: #ffb84d;
}
.button {
  margin: 0;
}
[class^="icon-"],
[class*=" icon-"] {
  font-family: FontAwesome;
  font-weight: normal;
  font-style: normal;
  text-decoration: inherit;
  margin: 0 0.4em 0 0;
  -webkit-font-smoothing: antialiased;
}
.icon-cog:before{content:'\f021'}

/* Content */
#content {
  display: table;
  margin: auto;
  background: rgba(0,0,0,0.7);
}

/* Desktop: table-cell layout for side-by-side */
@media screen and (min-width: 769px) {
  #d, #b, #c {
    display: table-cell;
  }
}

/* Canvases */
#sprite {
  display: none;
}
/*#bg {
  position: fixed;
  top:0;
  left:0;
  height:100%;
  width:100%;
  z-index: -1;
  opacity: 0;
  transition: opacity .5s ease-in;
}*/
#bg {
  position: fixed;
  top:0;
  left:0;
  height:100%;
  width:100%;
  z-index: -1;
}
#a {
  position: relative;
  overflow: hidden;
  float: left;
}
#b {
  border: 1px solid #fff;
  box-shadow: 0 0 20px rgba(255,255,255,0.5);
  position: relative;
  overflow: hidden;
  float: left;
  z-index: 3;
}
#c {
  padding: 0 0.5em;
  position: relative;
  overflow: hidden;
  float: left;
}

/* Reset floats for mobile - handled in mobile media query below */
  #bgStack {
    background: #000;
    position: absolute;
    z-index: 2;
  }
  #hold,
  #preview,
  #stack {
    position: absolute;
    z-index: 2;
  }
  #active {
    position: absolute;
    z-index: 3;
  }
  #msg {
    font-weight: 900;
    font-family: 'Source Sans Pro', sans-serif;
    line-height: 1.2;
    color: #fff;
    position: absolute;
    text-align: center;
    width: 100%;
    margin: 0;
    z-index: 4;
    /* Center vertically using transform */
    top: 50%;
    transform: translateY(-50%);
    /* Font size is set dynamically by resize() in tetris.js */
  }

  #hint {
    font-weight: 600;
    font-family: 'Source Sans Pro', sans-serif;
    line-height: 1.4;
    color: #fff;
    position: absolute;
    text-align: center;
    width: 90%;
    left: 50%;
    transform: translateX(-50%);
    margin: 0;
    padding: 8px 12px;
    z-index: 3;
    /* Position between top and center of board */
    top: 29%;
    background: rgba(0, 0, 0, 0.75);
    border-radius: 8px;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    /* Font size is set dynamically by resize() in tetris.js */
  }

  #hint.visible {
    opacity: 1;
  }

  /* Hide hold/next labels during tutorials */
  body.tutorial-mode #d h3,
  body.tutorial-mode #c h3 {
    display: none;
  }

  @keyframes successPop {
    0% {
      opacity: 0;
      transform: translateY(-50%) scale(0.5);
    }
    30% {
      opacity: 1;
      transform: translateY(-50%) scale(1.2);
    }
    70% {
      opacity: 1;
      transform: translateY(-50%) scale(1);
    }
    100% {
      opacity: 0;
      transform: translateY(-50%) scale(0.9);
    }
  }

  .success-animation {
    animation: successPop 0.6s ease-in-out;
    animation-fill-mode: forwards;
    will-change: transform, opacity;
    backface-visibility: hidden;
    -webkit-font-smoothing: antialiased;
  }

#d {
  float: left;
}

/* Stats */
#stats {
  display: block;
  position: absolute;
}
#stats tbody {
  display: block;
}
#stats tr {
  display: block;
  width: 100%;
  padding: 0 0.5rem;
}
#stats th {
  text-transform: uppercase;
  display: inline-block;
  width: 100%;
  vertical-align: top;
}
#stats td {
  font-size: 280%;
  font-weight: 900;
  text-align: center;
  line-height: 1;
  display: inline-block;
  width: 100%;
}
#time {
  text-align: center;
  font-weight: 900;
  font-size: 1.125em;
  display: block;
}

/* Menus */
.menu {
  text-align: center;
  width: 100%;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  margin-top: -200%;
  position: absolute;
  background: #000;
  background: rgba(0,0,0,0);
  top: 0;
  z-index: 50;
  opacity: 0;
  padding-bottom: 3em;
  /*-webkit-transition: opacity .4s ease-in-out;
     -moz-transition: opacity .4s ease-in-out;
       -o-transition: opacity .4s ease-in-out;*/
          transition: opacity .8s ease-out,
                      background .4s ease-out .3s,
                      margin .4s ease-out;
}

/* Widescreen menu layout - only when not in direct gameplay mode */
body:not(.url-direct-load) .menu {
  position: fixed;
  left: 0;
  right: 0;
  width: 100vw;
  max-width: 100%;
}

/* Center menu content in widescreen */
body:not(.url-direct-load) .menu > * {
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
}

/* Desktop: wider menu buttons for better use of space */
@media screen and (min-width: 769px) {
  body:not(.url-direct-load) .menu nav a,
  body:not(.url-direct-load) .menu .button,
  body:not(.url-direct-load) nav.menu a.menu-item-with-thumbnail {
    width: 70%;
    max-width: 600px;
  }

  body:not(.url-direct-load) .menu h1 {
    font-size: 3rem;
  }

  body:not(.url-direct-load) .menu h2 {
    font-size: 2rem;
  }
}

.on {
  background: rgba(0,0,0,0.8);
  opacity: 1;
  margin: 0;
}
.hidestat {
  display: none !important;;
}

/* Controls */
#controls {
  margin: 0 auto 1em;
  border-collapse: separate;
  border-spacing: 0.5em 0.3em;
}
#controls th {
  font-weight: bold;
  text-align: left;
  line-height: 1.6;
  padding-right: 1em;
}
#controls td {
  font-weight: bold;
  cursor: pointer;
  text-align: center;
  width: 6em;
  padding: 0.4em 0.8em;
  line-height: 1.6;
  background: #333;
  border-radius: 5px;
}
#controls td:hover {
  background: #444;
}

#controls td:active {
  background: #3a3a3a;
}

/* Mobile controls toggle button - ON state */
#mobileControlsToggle.on {
  background: #3b3;
}

#mobileControlsToggle.on:hover {
  background: #4c4;
}


/* Settings */
.left,
.right {
  font-weight: bold;
  font-style: normal;
  cursor: pointer;
  -webkit-font-smoothing: antialiased;
  -webkit-transition:all .1s ease-out;
  transition:all .1s ease-out;
  user-select: none;
}
.left:hover,
.right:hover {
  color: #4da6ee;
}
.left:before,
.right:before {
  text-decoration: inherit;
  display: inline-block;
}
.left:before  { content: "◀"; }
.right:before { content: "▶"; }

#settings {
  margin-bottom: 1em;
}
#settings b {
  text-align: left;
  display: inline-block;
  width: 7em;
}
#settings span {
  text-align: center;
  font-weight: bold;
  display: inline-block;
  width: 5em;
  margin: 0.3em 0;
}

/* Special Menus */
#go {
  background: none;
  transition: opacity .8s ease-out .8s;
}
#go ul {
  width: 100%;
  position: absolute;
  bottom: 2em;
}

#pause {
  background: none;
  transition: opacity .8s ease-out;
}
#pause ul {
  width: 100%;
  position: absolute;
  bottom: 2em;
}

/* Mobile Controls */
#mobile-controls {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  /* Base height + safe-area for iPhones with home indicator */
  height: calc(180px + env(safe-area-inset-bottom, 0px));
  background: rgba(0, 0, 0, 0.9);
  border-top: 2px solid rgba(255, 255, 255, 0.3);
  display: flex;
  justify-content: space-evenly;
  align-items: center;
  padding: 10px 5px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  z-index: 100;
  touch-action: none;
}

.mobile-controls-left {
  display: grid;
  grid-template-columns: repeat(3, 70px);
  grid-template-rows: repeat(4, 35px);
  gap: 8px;
  align-items: center;
  justify-content: center;
}

/* Arrow key layout:
     ↑
     ↑
   ← ↓ →
     ↓
   Up/down buttons span 2 rows each, left/right span all 4 rows */
#btn-hardDrop {
  grid-column: 2;
  grid-row: 1 / 3; /* Span 2 rows */
}

#btn-moveLeft {
  grid-column: 1;
  grid-row: 1 / 5; /* Span all 4 rows */
}

#btn-moveDown {
  grid-column: 2;
  grid-row: 3 / 5; /* Span 2 rows */
}

#btn-moveRight {
  grid-column: 3;
  grid-row: 1 / 5; /* Span all 4 rows */
}

.mobile-controls-right {
  display: grid;
  grid-template-columns: repeat(3, 65px);
  grid-template-rows: repeat(2, 65px);
  gap: 8px;
  align-items: center;
  justify-content: center;
}

.control-btn {
  background: rgba(255, 255, 255, 0.15);
  border: 2px solid rgba(255, 255, 255, 0.4);
  color: #fff;
  font-size: 1.5rem;
  font-weight: bold;
  border-radius: 8px;
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: all 0.1s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.control-btn:active,
.control-btn.pressed {
  background: rgba(77, 166, 238, 0.5);
  border-color: rgba(77, 166, 238, 0.8);
  transform: scale(0.95);
}

.dpad-btn {
  font-size: 2rem;
}

.action-btn {
  font-size: 1.2rem;
}

.utility-btn {
  font-size: 1.5rem;
}

#btn-holdPiece {
  font-size: 0.9rem;
}

/* Replay Speed Controls */
#replay-controls {
  position: fixed;
  bottom: 190px; /* Above mobile controls (180px + 10px gap) */
  left: 0;
  right: 0;
  height: 44px;
  background: rgba(0, 0, 0, 0.85);
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  z-index: 101;
}

.replay-label {
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.85rem;
  margin-right: 4px;
}

.replay-speed-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: 4px;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: all 0.15s ease;
  min-width: 42px;
}

.replay-speed-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.replay-speed-btn:active {
  transform: scale(0.95);
}

.replay-speed-btn.active {
  background: rgba(77, 166, 238, 0.6);
  border-color: rgba(77, 166, 238, 0.9);
  color: #fff;
}

.replay-indicator {
  color: rgba(77, 166, 238, 1);
  font-size: 0.9rem;
  font-weight: bold;
  margin-left: 8px;
  min-width: 32px;
  text-align: center;
}

/* Desktop: Position replay controls at top-right when no mobile controls */
@media screen and (min-width: 769px) {
  #replay-controls {
    position: fixed;
    top: 10px;
    bottom: auto;
    left: auto;
    right: 10px;
    width: auto;
    height: auto;
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(0, 0, 0, 0.8);
  }

  .replay-speed-btn {
    padding: 5px 8px;
    font-size: 0.8rem;
    min-width: 36px;
  }
}

/* Mobile Layout Adjustments */
/* Note: Layout spacing is now handled by resize() function in tetris.js,
   which calculates proper padding based on mobile controls height */
#content.mobile-layout {
  margin-top: 10px !important;
}

/* Mobile-specific responsive adjustments */
@media screen and (max-width: 768px) {
  #content {
    display: flex;
    flex-wrap: nowrap;
    justify-content: center;
    align-items: flex-start;
    margin: 5px auto 0;
    width: 100%;
    max-width: 100vw;
    gap: 0;
  }

  #a, #d, #b, #c {
    float: none;
  }

  #d {
    order: 1;
    flex: 1 1 0;
    min-width: 0;
    text-align: center;
    padding: 0 5px;
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  #b {
    order: 2;
    flex: 0 0 auto;
    margin: 0;
    padding: 0;
    width: auto;
  }

  #c {
    order: 3;
    flex: 1 1 0;
    min-width: 0;
    text-align: center;
    padding: 0 5px;
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  /* Reduce spacing for h3 headers on mobile */
  #d h3, #c h3 {
    font-size: 0.65rem;
    margin: 0.1em 0;
  }

  /* Make canvases smaller on mobile to fit */
  #hold, #preview {
    transform: scale(0.7);
    transform-origin: center center;
  }

  /* Center the hold canvas container */
  #a {
    text-align: center;
  }

  #a canvas {
    margin: 0 auto;
    display: block;
  }

  /* Center the preview canvas */
  #c canvas {
    margin: 0 auto;
    display: block;
    max-width: 100%;
  }

  h3 {
    font-size: 0.9rem;
    margin: 0.3em 0;
  }

  #stats {
    position: static;
    margin: 0.5em auto;
  }

  #stats tr {
    padding: 0.2rem;
  }

  #stats td {
    font-size: 180%;
  }

  nav li {
    margin: 0.3em auto;
  }

  nav a {
    width: 80%;
    font-size: 1rem;
    padding: 0.4rem 0.5rem;
  }

  /* Adjust progress bar width for skip button on mobile */
  nav a:has(.skip-btn) .progress-container {
    width: calc(100% - 4rem);
  }

  /* Smaller skip button on mobile */
  .skip-btn {
    font-size: 0.65rem;
    padding: 0.2rem 0.5rem;
  }

  h1 {
    font-size: 1.5rem;
    margin: 0.5em 0;
  }

  .subtitle {
    font-size: 0.8rem;
    margin: -1.5em 0 0.8em 0;
  }

  /* Disable transform on menu-focused items on mobile/touch to prevent touch hit testing issues */
  nav a.menu-focused,
  .button.menu-focused {
    transform: none;
  }

  nav a.menu-item-with-thumbnail.menu-focused {
    transform: none;
  }

  /* Adjust canvas sizes on very small screens */
  body.mobile-layout canvas {
    max-width: 90vw;
  }

  /* Fix modal content to not be hidden by mobile controls */
  .modal-content {
    padding-bottom: 200px;
  }
}

/* Very small screens (phones in portrait) */
@media screen and (max-width: 480px) {
  #mobile-controls {
    height: calc(160px + env(safe-area-inset-bottom, 0px));
    padding: 8px 3px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  }

  .mobile-controls-left {
    grid-template-columns: repeat(3, 60px);
    grid-template-rows: repeat(4, 30px);
    gap: 6px;
  }

  .mobile-controls-right {
    grid-template-columns: repeat(3, 55px);
    grid-template-rows: repeat(2, 55px);
    gap: 6px;
  }

  .dpad-btn {
    font-size: 1.8rem;
  }

  .action-btn {
    font-size: 1rem;
  }

  .utility-btn {
    font-size: 1.3rem;
  }

  #btn-holdPiece {
    font-size: 0.8rem;
  }

  /* Fix modal content for very small screens */
  .modal-content {
    padding-bottom: 180px;
  }
}

/* Landscape mode on mobile */
@media screen and (max-width: 896px) and (max-height: 428px) and (orientation: landscape) {
  #mobile-controls {
    height: calc(120px + env(safe-area-inset-bottom, 0px));
    padding: 5px 3px;
    padding-bottom: calc(5px + env(safe-area-inset-bottom, 0px));
  }

  .mobile-controls-left {
    grid-template-columns: repeat(3, 50px);
    grid-template-rows: repeat(4, 25px);
    gap: 5px;
  }

  .mobile-controls-right {
    grid-template-columns: repeat(3, 48px);
    grid-template-rows: repeat(2, 48px);
    gap: 5px;
  }

  .dpad-btn {
    font-size: 1.5rem;
  }

  .action-btn {
    font-size: 0.9rem;
  }

  .utility-btn {
    font-size: 1.2rem;
  }

  #btn-holdPiece {
    font-size: 0.7rem;
  }

  #content.mobile-layout {
    margin-top: 5px !important;
  }

  #content {
    margin-top: 5px;
  }

  h3 {
    font-size: 0.7rem;
    margin: 0.2em 0;
  }

  #stats tr {
    padding: 0.1rem;
  }

  /* Fix modal content for landscape mode */
  .modal-content {
    padding-bottom: 140px;
    max-height: 90vh;
  }
}

/* Welcome Modal Styles */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.8);
  animation: fadeIn 0.3s;
}

.modal.show {
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background-color: #1a1a1a;
  border: 2px solid #4da6ff;
  border-radius: 10px;
  padding: 30px;
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 4px 20px rgba(77, 166, 255, 0.3);
  animation: slideIn 0.3s;
}

.modal-content h2 {
  color: #4da6ff;
  margin-top: 0;
  font-size: 1.8rem;
  text-align: center;
}

.modal-content p {
  line-height: 1.6;
  margin: 15px 0;
}

.welcome-section {
  background-color: #252525;
  border-left: 3px solid #4da6ff;
  padding: 15px;
  margin: 20px 0;
  border-radius: 5px;
}

.welcome-section h3 {
  color: #4da6ff;
  margin-top: 0;
  font-size: 1.2rem;
}

.welcome-section ul {
  list-style: none;
  padding: 0;
  margin: 10px 0;
}

.welcome-section li {
  padding: 5px 0;
  font-size: 0.95rem;
}

.button-primary {
  background: linear-gradient(135deg, #4da6ff, #0066cc);
  color: white;
  border: none;
  padding: 12px 30px;
  font-size: 1.1rem;
  font-weight: bold;
  border-radius: 5px;
  cursor: pointer;
  width: 100%;
  margin-top: 20px;
  transition: transform 0.2s, box-shadow 0.2s;
}

.button-primary:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 15px rgba(77, 166, 255, 0.5);
}

.button-primary:active {
  transform: scale(0.98);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideIn {
  from {
    transform: translateY(-50px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}


/* URL Direct Load - Hide menus when loading directly into gameplay */
/* Exclude .banner-nav so the site header remains visible */
body.url-direct-load nav:not(.banner-nav) {
  display: none !important;
}
body.url-direct-load h1 {
  display: none !important;
}
body.url-direct-load .subtitle {
  display: none !important;
}

/* ============================================
   TWO-VIEW ARCHITECTURE
   ============================================ */

/* App container */
#app {
  width: 100%;
  min-height: 100vh;
}

/* View system - only one view active at a time */
.view {
  display: none;
  width: 100%;
  min-height: 100vh;
}

.view.active {
  display: block;
}

/* ============================================
   SITE BANNER - Shared header across all pages
   ============================================ */

.site-banner {
  background: #1a1a1a;
  border-bottom: 1px solid #2a2a2a;
  padding: 15px 40px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}

.site-banner .banner-left {
  display: flex;
  align-items: baseline;
  gap: 15px;
}

.site-banner .banner-logo {
  font-size: 28px;
  font-weight: 900;
  letter-spacing: 2px;
  background: linear-gradient(135deg, #00d4ff 0%, #c084fc 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-decoration: none;
  text-shadow: 0 0 1px rgba(0, 212, 255, 0.5);
}

.site-banner .banner-logo:hover {
  filter: brightness(1.1);
}

.site-banner .banner-tagline {
  color: #fff;
  font-size: 14px;
  font-weight: 300;
  margin-left: 5px;
  opacity: 0.7;
  text-transform: uppercase;
  letter-spacing: 2px;
}

.site-banner .banner-nav {
  display: flex;
  gap: 30px;
  align-items: center;
}

.site-banner .banner-nav-link {
  /* Reset nav a button styles */
  display: inline;
  width: auto;
  border: none;
  border-radius: 0;
  padding: 0;
  margin: 0;
  background: transparent;
  box-shadow: none;
  transform: none;
  /* Apply our styles */
  color: #888;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: color 0.3s ease;
}

.site-banner .banner-nav-link:hover {
  color: #00d4ff;
  transform: none;
  box-shadow: none;
}

.site-banner .banner-nav-link.active {
  color: #00d4ff;
}

.site-banner .banner-streak {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: rgba(128, 128, 128, 0.15);
  border: 1px solid rgba(128, 128, 128, 0.3);
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  color: #888;
}

.site-banner .banner-streak.has-streak {
  background: rgba(255, 165, 0, 0.15);
  border-color: rgba(255, 165, 0, 0.3);
  color: #ffa500;
}

.site-banner .banner-streak.active-today {
  background: rgba(57, 211, 83, 0.15);
  border-color: rgba(57, 211, 83, 0.3);
  color: #39d353;
}

/* Mobile banner adjustments */
@media (max-width: 600px) {
  .site-banner {
    padding: 12px 20px;
  }

  .site-banner .banner-logo {
    font-size: 20px;
  }

  .site-banner .banner-tagline {
    display: none;
  }

  .site-banner .banner-nav {
    gap: 20px;
  }
}

/* ============================================
   MENU VIEW - Modern card-based design
   ============================================ */

#menu-view {
  background: #0d0d0d;
  overflow-y: auto;
  padding-bottom: 2rem;
}

#menu-view .menu-container {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px;
}

/* Header */
#menu-view .menu-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 0;
  margin-bottom: 30px;
}

#menu-view .menu-header .logo {
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 2px;
  background: linear-gradient(135deg, #00d4ff 0%, #c084fc 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

#menu-view .nav-links {
  display: flex;
  gap: 20px;
}

#menu-view .nav-link {
  color: #888;
  text-decoration: none;
  font-size: 14px;
  transition: color 0.3s ease;
}

#menu-view .nav-link:hover {
  color: #00d4ff;
}

/* Hero Section */
#menu-view .menu-hero {
  text-align: center;
  padding: 40px 0;
  margin-bottom: 30px;
}

#menu-view .menu-hero h1 {
  font-size: 48px;
  font-weight: 800;
  background: linear-gradient(135deg, #fff 0%, #00d4ff 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 15px;
}

#menu-view .menu-hero p {
  color: #888;
  font-size: 18px;
  max-width: 500px;
  margin: 0 auto;
}

/* Stats Row */
#menu-view .stats-row {
  display: flex;
  justify-content: center;
  gap: 50px;
  margin: 30px 0;
}

#menu-view .stat-item {
  text-align: center;
}

#menu-view .stat-value {
  font-size: 32px;
  font-weight: 800;
  color: #00d4ff;
}

#menu-view .stat-label {
  font-size: 12px;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Primary CTA */
#menu-view .primary-cta {
  background: linear-gradient(135deg, #ff6b6b 0%, #ee5a5a 100%);
  border-radius: 16px;
  padding: 25px 30px;
  margin-bottom: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: all 0.3s ease;
  border: none;
  width: 100%;
  text-align: left;
  color: #fff;
}

#menu-view .primary-cta:hover {
  transform: translateY(-3px);
  box-shadow: 0 15px 40px rgba(255, 107, 107, 0.4);
}

#menu-view .cta-content {
  display: flex;
  align-items: center;
  gap: 20px;
}

#menu-view .cta-icon {
  font-size: 40px;
}

#menu-view .cta-text h3 {
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  margin: 0 0 5px 0;
}

#menu-view .cta-text p {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.8);
  margin: 0;
}

#menu-view .cta-badge {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  padding: 10px 20px;
  border-radius: 25px;
  font-weight: 700;
  font-size: 20px;
}

/* Quick Grid */
#menu-view .quick-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 15px;
  margin-bottom: 30px;
}

/* Wide viewport: all 4 buttons in one row */
@media (min-width: 900px) {
  #menu-view .quick-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

#menu-view .quick-btn {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid #2a2a2a;
  border-radius: 12px;
  padding: 20px 15px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  text-decoration: none;
  color: inherit;
}

#menu-view .quick-btn:hover {
  background: rgba(0, 212, 255, 0.1);
  border-color: #00d4ff;
}

#menu-view .quick-btn .icon {
  font-size: 28px;
  margin-bottom: 8px;
}

#menu-view .quick-btn .label {
  font-size: 14px;
  font-weight: 600;
}

/* Section */
#menu-view .menu-section {
  background: rgba(255, 255, 255, 0.03);
  border-radius: 16px;
  padding: 25px;
  margin-bottom: 25px;
  border: 1px solid #1a1a1a;
}

#menu-view .section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

#menu-view .section-title {
  font-size: 20px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0;
}

#menu-view .section-badge {
  background: #00d4ff;
  color: #000;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
}

#menu-view .view-all {
  color: #00d4ff;
  text-decoration: none;
  font-size: 14px;
  white-space: nowrap;
}

/* Mobile: fix section header overlap */
@media (max-width: 480px) {
  #menu-view .section-header {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: start;
    gap: 8px 12px;
  }

  #menu-view .section-title {
    flex-wrap: wrap;
    row-gap: 6px;
    font-size: 18px;
  }

  #menu-view .section-badge {
    font-size: 11px;
    padding: 3px 8px;
  }
}

/* Pattern List */
#menu-view .pattern-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#menu-view .pattern-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 15px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 12px;
  border: 1px solid #2a2a2a;
  cursor: pointer;
  transition: all 0.3s ease;
  text-decoration: none;
  color: inherit;
}

#menu-view .pattern-item:hover {
  background: rgba(0, 212, 255, 0.05);
  border-color: #00d4ff;
  transform: translateX(5px);
}

#menu-view .pattern-thumb {
  width: 70px;
  height: 50px;
  border-radius: 8px;
  object-fit: contain;
  background: #000;
  flex-shrink: 0;
}

#menu-view .pattern-info {
  flex: 1;
  min-width: 0;
}

#menu-view .pattern-name {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
}

#menu-view .pattern-meta {
  font-size: 13px;
  color: #666;
}

#menu-view .pattern-progress {
  width: 120px;
  flex-shrink: 0;
  position: relative;
}

#menu-view .progress-bar-mini {
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 4px;
}

#menu-view .progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #00d4ff 0%, #0088ff 100%);
  border-radius: 3px;
}

#menu-view .progress-fill.complete {
  background: linear-gradient(90deg, #39d353 0%, #26a641 100%);
}

#menu-view .progress-text {
  font-size: 12px;
  color: #00d4ff;
  text-align: right;
}

/* Progress text on completed bars - white for better contrast against green */
#menu-view .progress-bar.complete + .progress-text {
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
}

/* Pattern Request CTA */
#menu-view .pattern-request-cta {
  text-align: center;
  margin-top: 30px;
  padding: 16px 20px;
  background: linear-gradient(135deg, rgba(0, 212, 255, 0.08) 0%, rgba(192, 132, 252, 0.08) 100%);
  border: 1px solid rgba(0, 212, 255, 0.2);
  border-radius: 12px;
}

#menu-view .pattern-request-cta a {
  color: #aaa;
  text-decoration: none;
  font-size: 14px;
  transition: color 0.3s ease;
}

#menu-view .pattern-request-cta a:hover {
  color: #00d4ff;
}

/* Menu Footer */
#menu-view .menu-footer {
  display: flex;
  justify-content: center;
  gap: 30px;
  margin-top: 30px;
  padding-top: 20px;
  border-top: 1px solid #2a2a2a;
}

#menu-view .menu-footer a {
  color: #888;
  text-decoration: none;
  font-size: 14px;
}

#menu-view .menu-footer a:hover {
  color: #00d4ff;
}

/* ============================================
   PC PATTERN SUBMENUS (full pattern list views)
   ============================================ */

.pc-submenu-content {
  padding: 20px;
  max-width: 900px;
  margin: 0 auto;
}

.submenu-header {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 30px;
  padding-bottom: 20px;
  border-bottom: 1px solid #333;
}

.submenu-header .back-link {
  color: #00d4ff;
  text-decoration: none;
  font-size: 16px;
  padding: 8px 16px;
  border: 1px solid #00d4ff;
  border-radius: 8px;
  transition: all 0.3s ease;
}

.submenu-header .back-link:hover {
  background: rgba(0, 212, 255, 0.1);
}

.submenu-header h2 {
  font-size: 28px;
  font-weight: 700;
  color: #fff;
  margin: 0;
  flex: 1;
}

.submenu-badge {
  background: #00d4ff;
  color: #000;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
}

/* Mobile-optimized submenu header - single row, compact */
@media (max-width: 768px) {
  .submenu-header {
    gap: 10px;
    margin-bottom: 15px;
    padding-bottom: 12px;
    flex-wrap: nowrap;
  }

  .submenu-header .back-link {
    font-size: 14px;
    padding: 6px 10px;
    white-space: nowrap;
  }

  .submenu-header h2 {
    font-size: 16px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .submenu-badge {
    padding: 4px 10px;
    font-size: 12px;
    flex-shrink: 0;
  }
}

.submenu-patterns {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.submenu-patterns .pattern-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 15px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid #333;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-decoration: none;
  color: inherit;
}

.submenu-patterns .pattern-item:hover {
  background: rgba(0, 212, 255, 0.05);
  border-color: #00d4ff;
  transform: translateX(5px);
}

.submenu-patterns .pattern-thumb {
  width: 80px;
  height: 60px;
  background: #1a1a1a;
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
}

.submenu-patterns .pattern-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.submenu-patterns .pattern-info {
  flex: 1;
  min-width: 0;
}

.submenu-patterns .pattern-name {
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  margin-bottom: 4px;
}

.submenu-patterns .pattern-meta {
  font-size: 13px;
  color: #888;
}

.submenu-patterns .pattern-progress {
  width: 120px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.submenu-patterns .progress-bar-mini {
  width: 100%;
  height: 6px;
  background: #333;
  border-radius: 3px;
  overflow: hidden;
}

.submenu-patterns .progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #4CAF50, #45a049);
  transition: width 0.3s ease;
}

.submenu-patterns .progress-fill.complete {
  background: linear-gradient(90deg, #00d4ff, #0099cc);
}

.submenu-patterns .progress-text {
  font-size: 12px;
  color: #888;
}

/* All Patterns button in submenu */
.submenu-patterns .all-patterns-btn {
  background: rgba(0, 212, 255, 0.1);
  border-color: #00d4ff;
}

.submenu-patterns .all-patterns-btn:hover {
  background: rgba(0, 212, 255, 0.2);
}

/* Train All Learned button in submenu */
.submenu-actions {
  padding: 0 20px 16px;
}

.submenu-train-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 20px;
  background: linear-gradient(135deg, rgba(0, 212, 255, 0.15), rgba(0, 212, 255, 0.05));
  border: 1px solid rgba(0, 212, 255, 0.4);
  border-radius: 12px;
  color: #00d4ff;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.submenu-train-btn:hover {
  background: linear-gradient(135deg, rgba(0, 212, 255, 0.25), rgba(0, 212, 255, 0.1));
  border-color: rgba(0, 212, 255, 0.6);
  transform: translateY(-1px);
}

.submenu-train-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.submenu-train-btn .btn-icon {
  font-size: 20px;
}

.submenu-train-btn .btn-label {
  flex: 1;
}

.submenu-train-btn .btn-count {
  background: rgba(0, 212, 255, 0.2);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 14px;
  min-width: 30px;
  text-align: center;
}

/* ============================================
   IN-GAME MENUS (full-page in menu-view)
   ============================================ */

.ingame-menu-content {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}

.ingame-menu-container {
  max-width: 600px;
  width: 100%;
  text-align: center;
}

.ingame-title {
  font-size: 36px;
  font-weight: 800;
  background: linear-gradient(135deg, #fff 0%, #00d4ff 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 20px;
}

.ingame-stats {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 15px 20px;
  margin-bottom: 20px;
}

.ingame-stats .stat-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.ingame-stats .stat-row:last-child {
  border-bottom: none;
}

.ingame-stats .stat-label {
  color: #888;
  font-size: 14px;
}

.ingame-stats .stat-value {
  color: #fff;
  font-size: 16px;
  font-weight: 600;
}

.ingame-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 300px;
  margin: 20px auto 0;
}

.ingame-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  padding: 14px 24px;
  border-radius: 8px;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.ingame-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-2px);
}

.ingame-btn.primary {
  background: linear-gradient(135deg, #00d4ff 0%, #0099cc 100%);
  border-color: #00d4ff;
  font-weight: 600;
}

.ingame-btn.primary:hover {
  background: linear-gradient(135deg, #00e5ff 0%, #00aadd 100%);
  box-shadow: 0 4px 20px rgba(0, 212, 255, 0.3);
}

.ingame-btn.danger {
  border-color: rgba(255, 87, 34, 0.5);
}

.ingame-btn.danger:hover {
  background: rgba(255, 87, 34, 0.2);
  border-color: #ff5722;
}

/* Shimmer animation for highlighted buttons */
@keyframes btn-shimmer {
  0% { transform: translateX(-100%) translateY(-100%) rotate(45deg); }
  100% { transform: translateX(100%) translateY(100%) rotate(45deg); }
}

.ingame-btn.shimmer {
  position: relative;
  overflow: hidden;
}

.ingame-btn.shimmer::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(
    45deg,
    transparent 30%,
    rgba(255, 255, 255, 0.3) 50%,
    transparent 70%
  );
  animation: btn-shimmer 2.5s infinite;
  pointer-events: none;
}

/* Setup suggestion button (orange accent) */
.ingame-btn.setup-suggestion {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  text-align: left;
  border-color: rgba(255, 140, 50, 0.6);
  background: rgba(20, 20, 30, 0.95);
}

.ingame-btn.setup-suggestion:hover {
  border-color: rgba(255, 140, 50, 0.9);
  box-shadow: 0 4px 12px rgba(255, 140, 50, 0.3);
}

.ingame-btn.setup-suggestion .thumbnail {
  flex-shrink: 0;
  width: 60px;
  height: 40px;
  border-radius: 4px;
  border: 1px solid rgba(255, 140, 50, 0.4);
  object-fit: contain;
  background: rgba(0, 0, 0, 0.5);
}

.ingame-btn.setup-suggestion .btn-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ingame-btn.setup-suggestion .pattern-name {
  font-weight: 600;
  color: #fff;
}

.ingame-btn.setup-suggestion .pattern-action {
  font-size: 0.85em;
  color: rgba(255, 180, 100, 0.9);
}

/* Cyan accent variant for setup-suggestion (missed PC from setup) */
.ingame-btn.setup-suggestion.cyan-accent {
  border-color: rgba(0, 180, 255, 0.6);
}

.ingame-btn.setup-suggestion.cyan-accent:hover {
  border-color: rgba(0, 180, 255, 0.9);
  box-shadow: 0 4px 12px rgba(0, 180, 255, 0.3);
}

.ingame-btn.setup-suggestion.cyan-accent .pattern-action {
  color: rgba(100, 200, 255, 0.9);
}

.debug-info {
  margin-top: 20px;
  padding: 10px;
  font-size: 12px;
  color: #666;
  text-align: left;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 6px;
}

/* Hide debug-info when empty */
.debug-info:empty {
  display: none;
}

/* PC Analyzer container in game-over */
#pc-analyzer-container {
  margin: 20px 0;
  text-align: left;
}

/* PC Analyzer button container in fullpage game-over menu */
#pc-analyzer-button-container-fullpage:not(:empty) {
  margin-bottom: 12px;
}

/* ============================================
   SETTINGS MENU (full-page in menu-view)
   ============================================ */

.settings-menu-container {
  max-width: 500px;
  width: 100%;
  text-align: center;
}

.settings-panel {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 25px;
  margin-bottom: 30px;
  text-align: left;
}

.settings-section {
  margin-bottom: 25px;
}

.settings-section:last-child {
  margin-bottom: 0;
}

.settings-section-title {
  font-size: 14px;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 15px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* Controls Table */
.settings-controls-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 4px 4px;
}

.settings-controls-table th {
  text-align: left;
  padding: 8px 12px;
  color: #888;
  font-weight: normal;
  font-size: 14px;
  width: 35%;
}

.settings-controls-table td {
  padding: 8px 12px;
  text-align: center;
  background: rgba(42, 42, 74, 0.8);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  font-size: 14px;
  min-width: 70px;
  color: #fff;
}

.settings-controls-table td:hover {
  background: rgba(58, 58, 90, 0.9);
}

.settings-controls-table td.waiting {
  background: linear-gradient(135deg, #00d4ff 0%, #c084fc 100%);
  color: #000;
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* Handling Settings */
.settings-handling {
  margin-top: 10px;
}

.settings-row {
  display: flex;
  align-items: center;
  margin-bottom: 12px;
  gap: 12px;
}

.settings-row:last-child {
  margin-bottom: 0;
}

.settings-label {
  flex: 0 0 90px;
  font-size: 14px;
  color: #aaa;
}

.settings-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  background: rgba(42, 42, 74, 0.8);
  border-radius: 3px;
  outline: none;
}

.settings-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  background: linear-gradient(135deg, #00d4ff 0%, #c084fc 100%);
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.1s ease;
}

.settings-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.settings-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  background: linear-gradient(135deg, #00d4ff 0%, #c084fc 100%);
  border-radius: 50%;
  cursor: pointer;
  border: none;
}

.settings-value {
  flex: 0 0 50px;
  text-align: right;
  font-size: 14px;
  color: #00d4ff;
  font-family: monospace;
}

/* Toggle switch for settings */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 26px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #333;
  transition: 0.3s;
  border-radius: 26px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background-color: #888;
  transition: 0.3s;
  border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
  background-color: #00d4ff;
}

.toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(24px);
  background-color: #fff;
}

.settings-hint {
  font-size: 12px;
  color: #666;
  margin: 8px 0 0 0;
  padding: 0;
}

.settings-warning {
  color: #ff6b6b;
}

/* Responsive for in-game menus */
@media (max-width: 600px) {
  .ingame-title {
    font-size: 28px;
  }

  .ingame-stats {
    padding: 15px;
  }

  .ingame-btn {
    padding: 12px 20px;
    font-size: 14px;
  }
}

/* ============================================
   GAME VIEW - Existing canvas layout
   ============================================ */

#game-view {
  background: #000;
  overflow: hidden;
  /* Prevent the view from being taller than viewport minus header */
  max-height: calc(100vh - 70px);
  /* Ensure content doesn't get hidden under sticky header at high zoom */
  min-height: calc(100vh - 70px);
}

/* Game header (back button) */
#game-view #game-header {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 100;
}

#game-view #game-header button {
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid #333;
  color: #fff;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}

#game-view #game-header button:hover {
  background: rgba(0, 212, 255, 0.2);
  border-color: #00d4ff;
}

/* ============================================
   RESPONSIVE - Menu View
   ============================================ */

@media (max-width: 768px) {
  #menu-view .menu-container {
    padding: 15px;
  }

  #menu-view .menu-hero h1 {
    font-size: 32px;
  }

  #menu-view .menu-hero p {
    font-size: 15px;
  }

  #menu-view .stats-row {
    gap: 30px;
  }

  #menu-view .stat-value {
    font-size: 24px;
  }

  #menu-view .primary-cta {
    flex-direction: column;
    text-align: center;
    gap: 15px;
  }

  #menu-view .cta-content {
    flex-direction: column;
  }

  #menu-view .quick-grid {
    grid-template-columns: 1fr;
  }

  #menu-view .pattern-item {
    flex-wrap: wrap;
  }

  #menu-view .pattern-progress {
    width: 100%;
    order: 4;
    margin-top: 10px;
  }
}

/* ============================================
   HARD PATTERN BADGE
   ============================================ */
.hard-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 8px;
  margin-left: 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #fff;
  background: linear-gradient(180deg, #ff9600 0%, #e58800 100%);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(255, 150, 0, 0.3);
  vertical-align: middle;
}

@media (max-width: 768px) {
  .hard-badge {
    padding: 1px 6px;
    font-size: 10px;
  }
}
