* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Arial, sans-serif;
  background: #0d0f10;
  color: white;
  overflow: hidden;
}

.hidden { display: none !important; }

.screen {
  width: 100vw;
  height: 100vh;
}

.hub-screen {
  background:
    radial-gradient(circle at 30% 20%, rgba(255,255,255,0.12), transparent 35%),
    linear-gradient(135deg, #20262b, #111315 62%, #080909);
}

.daily-card h2 {
  margin: 0;
}

.muted,
#status,
.message {
  color: rgba(255,255,255,0.68);
}

.profile-dropdown input {
  width: 100%;
  padding: 11px 12px;
  margin-top: 10px;
  border: 1px solid rgba(255,255,255,0.22);
  background: rgba(255,255,255,0.08);
  color: white;
  outline: none;
}

button,
select {
  padding: 8px 12px;
  border: 1px solid rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.13);
  color: white;
  cursor: pointer;
}

button:hover { background: rgba(255,255,255,0.2); }
button.secondary { background: rgba(255,255,255,0.06); }
button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.big-button {
  width: 100%;
  margin-top: 14px;
  padding: 16px 18px;
  font-size: 17px;
  font-weight: 700;
  background: rgba(255,255,255,0.9);
  color: #111;
}

.big-button:disabled {
  background: rgba(255,255,255,0.26);
  color: rgba(255,255,255,0.7);
}

.hub-screen { padding: 28px; }
.hub-shell { max-width: 1180px; margin: 0 auto; }

.hub-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 24px;
}

.eyebrow,
.card-label {
  color: rgba(255,255,255,0.55);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 8px;
}

.site-logo {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
}

.logo-mark {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(255,255,255,0.28);
  background: rgba(255,255,255,0.1);
  border-radius: 10px;
  font-size: 22px;
  letter-spacing: 0;
}

.logo-text { text-transform: lowercase; }

.today-label {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.today-date {
  color: rgba(255,255,255,0.78);
  letter-spacing: 0;
  text-transform: none;
  font-size: 13px;
}

.profile-menu { position: relative; }
.profile-button { min-width: 140px; text-align: left; }

.profile-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: 300px;
  padding: 16px;
  z-index: 20;
  background: rgba(8,10,11,0.96);
  border: 1px solid rgba(255,255,255,0.18);
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);
}

.profile-dropdown label {
  display: block;
  margin-top: 14px;
  color: rgba(255,255,255,0.62);
  font-size: 12px;
}

.profile-dropdown button { width: 100%; margin-top: 10px; }
.profile-auth-panel { margin-top: 12px; }
.profile-email { font-size: 13px; color: rgba(255,255,255,0.7); overflow-wrap: anywhere; }

.hub-grid {
  display: grid;
  grid-template-columns: 1.25fr 0.85fr;
  grid-template-rows: auto auto;
  gap: 18px;
}

.daily-card {
  padding: 24px;
  min-height: 220px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.16);
  box-shadow: 0 20px 70px rgba(0,0,0,0.25);
}

.primary-card {
  min-height: 360px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.puzzle-hero-wrap {
  flex: 1;
  min-height: 220px;
  margin-bottom: 22px;
  border: 1px solid rgba(255,255,255,0.16);
  background: rgba(0,0,0,0.25);
  overflow: hidden;
  display: grid;
  place-items: center;
}

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

.primary-card h2 { font-size: 34px; }
.calendar-card { grid-column: 1 / -1; }

.leaderboard-list {
  margin: 18px 0 0;
  padding-left: 26px;
  min-height: 130px;
}

.leaderboard-list li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.rank-box {
  margin-top: 14px;
  padding: 12px;
  background: rgba(0,0,0,0.25);
  border: 1px solid rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.78);
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(92px, 1fr));
  gap: 8px;
  margin-top: 16px;
}

.calendar-day {
  min-height: 68px;
  padding: 10px;
  text-align: left;
  background: rgba(0,0,0,0.24);
}

.calendar-day.active {
  background: rgba(255,255,255,0.9);
  color: #111;
}

.calendar-date {
  display: block;
  font-weight: 700;
}

.calendar-title {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  opacity: 0.72;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#gameShell {
  width: 100vw;
  height: 100vh;
  background: #000;
}

#bar {
  height: 52px;
  padding: 8px;
  box-sizing: border-box;
  display: flex;
  gap: 8px;
  align-items: center;
  background: #6c7a89;
}

body.complete #bar { display: none; }

.game-bar-spacer { margin-left: auto; }
#gameStatus { color: rgba(255,255,255,0.85); }

canvas {
  display: block;
  background: #b0aa9c;
}

@media (max-width: 860px) {
  .hub-grid { grid-template-columns: 1fr; }
  .calendar-grid { grid-template-columns: repeat(3, 1fr); }
  .hub-header h1 { font-size: 30px; }
}


.logo-icon{
  width:40px;
  height:40px;
  object-fit:contain;
  display:block;
}


.image-load-failed{
  opacity:.35;
  background:rgba(255,255,255,.08);
}


.puzzle-meta {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  margin: 0 0 12px;
  padding: 6px 9px;
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.82);
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
}

.calendar-meta {
  display: block;
  margin-top: 5px;
  font-size: 11px;
  color: rgba(255,255,255,0.52);
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  line-height: 1.25;
}

.calendar-day.active .calendar-meta {
  display: block;
  margin-top: 5px;
  font-size: 11px;
  color: rgba(255,255,255,0.52);
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  line-height: 1.25;
}


.hub-actions {
  display: flex;
  align-items: stretch;
  gap: 10px;
  margin-top: 14px;
}

.hub-actions .big-button {
  flex: 1;
  margin-top: 0;
}

.restart-button {
  min-width: 112px;
  padding: 16px 18px;
  font-size: 15px;
  font-weight: 700;
}


.confirm-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px;
}

.confirm-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.62);
  backdrop-filter: blur(6px);
}

.confirm-modal-card {
  position: relative;
  width: min(440px, 100%);
  padding: 24px;
  background: rgba(14,17,19,0.98);
  border: 1px solid rgba(255,255,255,0.18);
  box-shadow: 0 30px 90px rgba(0,0,0,0.62);
}

.confirm-modal-card h2 {
  margin: 0 0 10px;
  font-size: 24px;
}

.confirm-modal-card p {
  margin: 0;
  color: rgba(255,255,255,0.72);
  line-height: 1.45;
}

.confirm-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

.confirm-modal-actions button {
  min-width: 112px;
  padding: 11px 14px;
  font-weight: 700;
}

button.danger {
  background: rgba(255,78,78,0.92);
  border-color: rgba(255,130,130,0.55);
  color: white;
}

button.danger:hover {
  background: rgba(255,96,96,1);
}


.calendar-status {
  display: inline-block;
  margin-top: 6px;
  padding: 2px 6px;
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgba(255,255,255,0.58);
}

.calendar-day.started .calendar-status {
  border-color: rgba(255,255,255,0.28);
  color: rgba(255,255,255,0.86);
}

.calendar-day.completed .calendar-status {
  border-color: rgba(255,255,255,0.38);
  color: rgba(255,255,255,0.95);
}

.calendar-day.active .calendar-status {
  border-color: rgba(0,0,0,0.24);
  color: rgba(0,0,0,0.72);
}

.calendar-time {
  margin-top: 3px;
  color: rgba(255,255,255,0.44);
}


.calendar-day.active .calendar-date,
.calendar-day.active .calendar-title {
  color: rgba(0,0,0,0.88);
  opacity: 1;
}

.calendar-day.active .calendar-meta {
  color: rgba(0,0,0,0.68);
  opacity: 1;
}

.calendar-day.active .calendar-time {
  color: rgba(0,0,0,0.58);
  opacity: 1;
}


.build-info {
  position: fixed;
  top: 8px;
  right: 8px;
  left: auto;
  z-index: 9999;
  padding: 4px 7px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  color: rgba(255, 255, 255, 0.72);
  font: 11px/1.2 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  pointer-events: none;
  user-select: none;
}


.loading-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  background: rgba(0,0,0,0.62);
  backdrop-filter: blur(5px);
}

.loading-modal.hidden { display: none; }

.loading-card {
  width: min(420px, calc(100vw - 48px));
  padding: 28px;
  background: rgba(16,16,18,0.96);
  border: 1px solid rgba(255,255,255,0.16);
  box-shadow: 0 24px 80px rgba(0,0,0,0.45);
  text-align: center;
}

.loading-card h2 {
  margin-bottom: 8px;
  font-size: 24px;
}

.loading-card p {
  margin-bottom: 18px;
  color: rgba(255,255,255,0.72);
}

.loading-progress-track {
  height: 12px;
  overflow: hidden;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.16);
}

.loading-progress-fill {
  width: 0%;
  height: 100%;
  background: rgba(255,255,255,0.9);
  transition: width 180ms ease;
}

.game-active .build-info {
  display: none;
}

.game-logo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-right: 8px;
  font-weight: 800;
  letter-spacing: -0.04em;
  white-space: nowrap;
}

.game-logo-icon {
  width: 28px;
  height: 28px;
  object-fit: contain;
  display: block;
}

.game-logo-text {
  font-size: 20px;
  line-height: 1;
}

#bar #gameTitle {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 42vw;
}


.reference-modal {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 72px 36px 44px;
  background: rgba(0,0,0,0.84);
  backdrop-filter: blur(6px);
}

.reference-modal.hidden { display: none; }

.reference-stage {
  width: min(92vw, 1400px);
  height: min(82vh, 900px);
  display: grid;
  place-items: center;
  overflow: hidden;
  touch-action: none;
  cursor: grab;
}

.reference-stage:active { cursor: grabbing; }

.reference-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  box-shadow: 0 24px 90px rgba(0,0,0,0.58);
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(0,0,0,0.25);
  user-select: none;
  touch-action: none;
  transform-origin: center center;
  will-change: transform;
}

.reference-close {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 71;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  padding: 0;
  font-size: 30px;
  line-height: 1;
  background: rgba(255,255,255,0.12);
}

.reference-hint {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  padding: 7px 11px;
  border-radius: 999px;
  background: rgba(0,0,0,0.46);
  color: rgba(255,255,255,0.7);
  font-size: 12px;
  pointer-events: none;
}

#referenceBtn {
  white-space: nowrap;
}

.test-mode-badge {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 10000;
  padding: 7px 10px;
  border: 1px solid rgba(255, 210, 80, .55);
  border-radius: 999px;
  background: rgba(50, 38, 0, .86);
  color: #ffe08a;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  pointer-events: none;
}

.calendar-day.test-puzzle {
  border-color: rgba(255, 210, 80, .45);
}

.calendar-test-status {
  color: #ffe08a;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.completion-review-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px;
}

.completion-review-modal.hidden { display: none; }

.completion-review-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.72);
  backdrop-filter: blur(7px);
}

.completion-review-card {
  position: relative;
  width: min(720px, 100%);
  max-height: 92vh;
  overflow: auto;
  padding: 24px;
  background: rgba(14,17,19,0.98);
  border: 1px solid rgba(255,255,255,0.18);
  box-shadow: 0 30px 90px rgba(0,0,0,0.62);
}

.completion-review-card h2 {
  margin: 0 44px 16px 0;
  font-size: 26px;
}

.completion-review-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 38px;
  height: 38px;
  border-radius: 999px;
  padding: 0;
  font-size: 26px;
  line-height: 1;
  background: rgba(255,255,255,0.1);
}

.completion-review-image {
  width: 100%;
  max-height: 56vh;
  object-fit: contain;
  display: block;
  background: rgba(0,0,0,0.28);
  border: 1px solid rgba(255,255,255,0.14);
}

.completion-review-stats {
  margin-top: 16px;
  padding: 14px;
  background: rgba(0,0,0,0.25);
  border: 1px solid rgba(255,255,255,0.12);
}

.completion-review-stat-row {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.completion-review-stat-row:last-child {
  border-bottom: 0;
}

.completion-review-stat-row span {
  color: rgba(255,255,255,0.78);
  text-align: right;
}

.completion-review-note {
  margin-top: 10px;
  color: #ffe08a;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.completion-review-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.completion-review-actions button {
  min-width: 112px;
  padding: 11px 14px;
  font-weight: 700;
}

/* v0.3.0 desktop-first UI pass */
button,
select,
.profile-dropdown input {
  min-height: 44px;
}

body {
  padding-top: env(safe-area-inset-top);
  padding-right: env(safe-area-inset-right);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
}

.screen-advice {
  position: fixed;
  left: 50%;
  top: calc(16px + env(safe-area-inset-top));
  z-index: 10001;
  width: min(560px, calc(100vw - 24px));
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border: 1px solid rgba(255,255,255,0.24);
  background: rgba(12,14,15,0.96);
  box-shadow: 0 18px 60px rgba(0,0,0,0.45);
  transform: translateX(-50%);
}

.screen-advice strong {
  display: block;
  margin-bottom: 3px;
  font-size: 14px;
}

.screen-advice p {
  margin: 0;
  color: rgba(255,255,255,0.72);
  font-size: 13px;
  line-height: 1.35;
}

.screen-advice-dismiss {
  flex: 0 0 auto;
  font-weight: 700;
  white-space: nowrap;
}

.game-screen-advice {
  position: fixed;
  left: 50%;
  top: calc(60px + env(safe-area-inset-top));
  z-index: 55;
  transform: translateX(-50%);
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(0,0,0,0.56);
  color: rgba(255,255,255,0.78);
  font-size: 12px;
  pointer-events: none;
}

.confirm-modal,
.completion-review-modal,
.loading-modal,
.reference-modal {
  padding-left: max(24px, env(safe-area-inset-left));
  padding-right: max(24px, env(safe-area-inset-right));
}

.confirm-modal-card,
.completion-review-card,
.loading-card {
  max-width: calc(100vw - 32px);
}

.completion-review-card {
  max-height: min(92vh, 860px);
}

.reference-stage {
  width: min(90vw, 1320px);
  height: min(78vh, 840px);
}

.reference-close,
.completion-review-close {
  min-height: 44px;
  min-width: 44px;
}

#bar {
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

#bar button {
  flex: 0 0 auto;
  min-width: 44px;
}

@media (min-width: 861px) and (max-width: 1180px) {
  .hub-screen { padding: 24px; }
  .hub-grid { grid-template-columns: 1fr 0.9fr; }
  .calendar-grid { grid-template-columns: repeat(5, minmax(96px, 1fr)); }
  .primary-card h2 { font-size: 30px; }
  .daily-card { padding: 20px; }
}

@media (min-width: 700px) and (max-width: 900px) {
  .hub-screen { padding: 22px; overflow-y: auto; }
  .screen { min-height: 100vh; height: auto; }
  .hub-grid { grid-template-columns: 1fr; }
  .calendar-grid { grid-template-columns: repeat(4, minmax(110px, 1fr)); }
  .puzzle-hero-wrap { min-height: 260px; }
  .reference-stage { width: 92vw; height: 76vh; }
}

@media (max-width: 699px) {
  body { overflow: auto; }
  .hub-screen { padding: 88px 12px 16px; overflow-y: auto; }
  .screen { min-height: 100vh; height: auto; }
  .hub-shell { max-width: 100%; }
  .hub-header {
    align-items: stretch;
    gap: 12px;
    flex-direction: column;
    margin-bottom: 14px;
  }
  .site-logo { font-size: 24px; }
  .logo-icon { width: 34px; height: 34px; }
  .profile-menu { width: 100%; }
  .profile-button { width: 100%; text-align: center; }
  .profile-dropdown {
    position: static;
    width: 100%;
    margin-top: 8px;
  }
  .hub-grid { grid-template-columns: 1fr; gap: 12px; }
  .daily-card { padding: 16px; min-height: 0; }
  .primary-card { min-height: 0; }
  .primary-card h2 { font-size: 26px; }
  .puzzle-hero-wrap { min-height: 190px; margin-bottom: 16px; }
  .hub-actions { flex-wrap: wrap; }
  .hub-actions .big-button { flex-basis: 100%; }
  .restart-button { flex: 1 1 120px; }
  .calendar-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .calendar-day { min-height: 76px; }
  .leaderboard-list li { grid-template-columns: 1fr; gap: 4px; }
  .screen-advice {
    top: calc(10px + env(safe-area-inset-top));
    align-items: stretch;
    flex-direction: column;
  }
  .screen-advice-dismiss { width: 100%; }
  #gameShell { overflow: hidden; }
  #bar {
    height: 52px;
    gap: 6px;
    padding: 6px;
    white-space: nowrap;
  }
  .game-logo-text { display: none; }
  .game-logo { margin-right: 0; }
  #bar #gameTitle { max-width: 140px; font-size: 13px; }
  #gameStatus,
  #saveStatus { display: none; }
  .reference-modal { padding: 68px 12px 44px; }
  .reference-stage { width: 94vw; height: 72vh; }
  .reference-hint {
    width: calc(100vw - 24px);
    border-radius: 12px;
    text-align: center;
    line-height: 1.35;
  }
  .completion-review-modal,
  .confirm-modal,
  .loading-modal { padding: 12px; }
  .completion-review-card,
  .confirm-modal-card,
  .loading-card { padding: 18px; }
  .completion-review-image { max-height: 42vh; }
  .completion-review-actions,
  .confirm-modal-actions { flex-direction: column-reverse; }
  .completion-review-actions button,
  .confirm-modal-actions button { width: 100%; }
  footer { padding-bottom: calc(18px + env(safe-area-inset-bottom)) !important; }
}

@media (max-height: 520px) and (max-width: 950px) {
  .hub-screen { padding-top: 72px; }
  .puzzle-hero-wrap { min-height: 130px; }
  .screen-advice { flex-direction: row; }
  .screen-advice p { display: none; }
  .reference-stage { height: 62vh; }
  .completion-review-image { max-height: 34vh; }
}
