/* ===========================
   CONTENT ORIGINALLY FROM style.css
   (external file)
=========================== */

/* OPTIONAL utility class */
.hidden {
  display: none !important;
}

/* Existing styling from your original index.html */
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, Helvetica, Arial, sans-serif;
  background: #0b1020;
  color: #f5f5f5;
  min-height: 100vh;
  align-items: flex-start;
  justify-content: center;
}
.page {
  width: 100%;
  max-width: 480px;
  padding: 24px;
}
.card {
  background: #141a30;
  border-radius: 16px;
  padding: 24px 20px 20px;
  box-shadow: 0 16px 30px rgba(0, 0, 0, 0.35);
}
h1 {
  margin: 0;
  text-align: center;
  font-size: 2.4rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.subtitle-main {
  text-align: center;
  margin-top: 6px;
  margin-bottom: 18px;
  font-size: 0.9rem;
  opacity: 0.75;
}
.section {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.section:first-of-type {
  margin-top: 4px;
  border-top: none;
  padding-top: 0;
}
.section-title {
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  opacity: 0.85;
  margin-bottom: 12px;
}
.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.btn {
  flex: 1 1 calc(50% - 10px);
  min-width: 120px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: linear-gradient(
    135deg,
    rgba(70, 186, 120, 0.12),
    rgba(70, 186, 220, 0.05)
  );
  color: #f5f5f5;
  font-size: 0.95rem;
  cursor: pointer;
  text-align: center;
  transition: transform 0.08s ease, box-shadow 0.08s ease,
    background 0.12s ease, border-color 0.12s ease;
}
.btn.full-width {
  flex: 1 1 100%;
}
.btn:hover {
  background: linear-gradient(
    135deg,
    rgba(70, 186, 120, 0.25),
    rgba(70, 186, 220, 0.14)
  );
  border-color: rgba(255, 255, 255, 0.4);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.35);
  transform: translateY(-1px);
}
.btn:active {
  transform: translateY(0);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35);
}
.footer-note {
  margin-top: 16px;
  font-size: 0.8rem;
  opacity: 0.6;
  text-align: center;
}

h3 {
  text-decoration: underline;
}

/* Additional styling for tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
}
td {
  border: 1px solid rgba(255,255,255,0.15);
  padding: 6px;
  text-align: center;
  cursor: pointer;
}
td.blank {
  cursor: default;
  opacity: 0.2;
}
td.selected {
  color: gold;
  font-weight: bold;
}

@media (max-width: 480px) {
  .card {
    padding: 20px 16px 16px;
  }
  h1 {
    font-size: 2rem;
  }
}

/* ===========================
   CONTENT ORIGINALLY FROM index.html <style> BLOCK
=========================== */

/* Start by hiding the non-home screens */
#levelSelectScreen,
#gameplayScreen {
  display: none;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden; /* no page scroll */
  overscroll-behavior: none;
  background: #050816;
  touch-action: none; 
  overscroll-behavior-x: none;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, Helvetica, Arial, sans-serif;
}

/* Root container that holds all three screens */
#gameScreen {
  width: 100vw;
  height: 100dvh;
  margin: 0;
  display: flex;
  align-items: stretch;
  justify-content: center;
  background: #050816;
}




table {
  border-collapse: collapse;
  border: none !important;
}

table td,
table th {
  border: none !important;
}


/* Canvas wrapper for padding/centering */
#puzzle {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 12px;        /* prevents touching edges */
  box-sizing: border-box;
  width: 100%;
  height: calc(100dvh - TOOLBAR_HEIGHTpx);
}

/* Each "screen" fills the viewport */
#homeScreen,
#levelSelectScreen,
#gameplayScreen {
  width: 100%;
  height: 100%;
  display: none; /* only one visible at a time */
}

#homeScreen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center; /* Home should stay centered */
  text-align: center;
}

#levelSelectScreen {
  display: flex;
  flex-direction: column;
  align-items: center;
  /* ❌ REMOVE justify-content:center */
  text-align: center;
}


/* Show home screen by default (JS will override if needed) */
#homeScreen {
  display: flex;
}

/* ===========================
   HOME SCREEN
=========================== */

#homeScreen img {
  display: block;
  margin: 0 auto;
}

.belt-img {
  width: 160px;
  margin-top: 20px;
}

#beltTable {
  border-spacing: 10px;
}

#beltTable button {
  padding: 10px 14px;
  margin: 6px;
  font-size: 16px;
  min-width: 100px;
  border-radius: 999px;
}

.disabled-btn {
  opacity: 0.4;
}

/* ===========================
   LEVEL SELECT SCREEN
=========================== */

#levelSelectScreenHeader {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 10px 16px;
  box-sizing: border-box;
}

#returnHomeBtn {
  width: 44px;
  height: 44px;
  font-size: 20px;
  margin-right: 10px;
}

#levelSelectBeltImg {
  height: 40px;
}

#levelTable {
  margin: 0 auto;
  border-spacing: 8px;
}

.level-btn {
  width: 60px;
  height: 60px;
  font-size: 20px;
  border-radius: 999px;
}

.level-btn.level-complete {
  background-color: #66bb6a;
  border: 2px solid #2e7d32;
  color: white;
}

.level-btn:disabled {
  opacity: 0.4;
}


/* === Fix: Keep home + levelSelect buttons aligned to title image === */
#homeScreen .content-wrapper,
#levelSelectScreen .content-wrapper {
  width: max-content;       /* shrink to fit contents */
  max-width: 100%;          /* but never overflow */
  margin: 0 auto;           /* center it */
}

#titleImg {
  display: block;
  margin: 0 auto;
  width: 260px;              /* Set your desired stable width */
  max-width: 80%;            /* scales on tiny screens */
}

#homeScreen {
  padding-top: 10px;     /* reduce top gap */
}

#beltDisplay img.belt-img {
  width: 260px;           /* match #titleImg width */
  max-width: 80%;         /* scale on small screens */
  display: block;
  margin: 12px auto 0;    /* tighten spacing */
}

/* ===========================
   GAMEPLAY SCREEN
=========================== */

#gameplayScreen {
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  text-align: center;
}

#gameBeltImg {
  height: 30px;
  flex-shrink: 0;
}

#levelText {
  font-size: 20px;
  flex-grow: 1;
  text-align: center;
}

/* Puzzle area: fills the rest of the screen */
#puzzle {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  box-sizing: border-box;
}

#puzzleCanvas {
  width: 100%;
  height: 100%;
  max-width: 1000px;
  max-height: 1000px;
  background: #050816;
  border: none;

  /* Touch behaviour */
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

/* ===========================
   TOOLBAR
=========================== */



#toolbarBar {
  width: 100%;
  background: #050816; 
  border-bottom: solid calc(var(--toolbar-height) * 0.15) #f5e6c8; /* match puzzle line */
  border-top: 2px solid #1f2937;
  display: flex;
  justify-content: center;
  box-sizing: border-box;
}

/* Centered cluster of 5 controls inside the full-width bar */
#toolbar {
  --toolbar-height: clamp(
      42px,                 /* minimum */
      14vw,                 /* proportional scaling factor */
      60px                  /* Pixel 8 baseline (max) */
  );


.hiddenBtn {
  visibility: hidden;
}

  height: var(--toolbar-height);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: clamp(12px, calc(var(--toolbar-height) * 0.55), 32px);

  background: #0b1020;                     /* dark blue box */
  box-sizing: border-box;

  width: max-content;
  margin: 0 auto;

  /* ⭐ Puzzle-line border around whole toolbar */
  border: calc(var(--toolbar-height) * 0.15) solid #f5e6c8;
  border-radius: 12px;                      /* matches round line caps */
}


/* PASU title in the middle */
#toolbarTitleImg {
  height: calc(var(--toolbar-height) * 0.9);
  flex-shrink: 0;
  width: auto;
  object-fit: contain;
}

/* All toolbar buttons: back, refresh, next */
.toolbar-btn {
  width: calc(var(--toolbar-height) * 0.60);
  height: calc(var(--toolbar-height) * 0.60);
  border: none;
  background: none;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  flex-shrink: 0;
}

.toolbar-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

/* Icon inside any toolbar button (backarrow, forwardarrow, refresh) */
.toolbar-btn .toolbar-icon {
  height: 70%;          /* relative to button height */
  width: auto;
  object-fit: contain;
  pointer-events: none; /* clicks go to button, not image */
}

/* Belt + level number wrapper (positioning anchor) */
#beltLevelWrapper {
  position: relative;
  width: auto;
  height: calc(var(--toolbar-height) * 0.60);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin: 0 4px;
}

/* Belt image */
#gameBeltImg {
  height: calc(var(--toolbar-height) * 0.38);
  display: block;
  margin-bottom: 14px;    /* no extra gap, we control overlap via levelText */
}

/* Level number, slightly overlapping / tucked under belt */
#levelText {
  position: absolute;
  bottom: -2px;                    /* tweak this for closer/further overlap */
  left: 50%;
  transform: translateX(-50%);
  font-size: calc(var(--toolbar-height) * 0.33);
  line-height: 1;
  white-space: nowrap;
  pointer-events: none;
}


#refreshBtn .toolbar-icon {
  height: 140%;   /* try 45%, 50%, 60%, etc. */
}


/* ===========================
   RESPONSIVE HEIGHTS
=========================== */

/* Mobile: toolbar ~10% of the screen */
@media (max-width: 768px) {
  #toolbar {
    height: 10vh;
    min-height: 48px;
    max-height: 80px;
  }
  #puzzle {
    height: calc(100dvh - 10vh);
  }
}

/* Desktop/tablet: toolbar fixed ~64px */
@media (min-width: 769px) {
  #toolbar {
    height: 64px;
  }

  table {
    border-collapse: collapse;
  }
  td {
    border: none;
  }
}
