/* =========================================================
   Schulte Grid
   Ivan World · Games
   ========================================================= */


/* =========================================================
   Base
   ========================================================= */

* {
  box-sizing: border-box;
}


html {
  min-width: 320px;
  min-height: 100%;
}


body {
  min-height: 100vh;
  margin: 0;

  overflow-x: hidden;

  color: var(--foreground);
  font-family: var(--font-sans);
}


button,
input {
  font: inherit;
}


button,
a,
input {
  -webkit-tap-highlight-color: transparent;
}


a {
  color: inherit;
}


.hidden {
  display: none !important;
}


/* =========================================================
   Page
   ========================================================= */

.page-wrap {
  width: min(100%, 1380px);
  min-height: 100svh;

  margin: 0 auto;
  padding: 30px 28px 24px;
}


/* =========================================================
   Header
   与 Ball Attention 保持同一套尺寸
   ========================================================= */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;

  gap: 24px;
  margin-bottom: 26px;
}


.brand-lockup {
  display: flex;
  align-items: center;
  gap: 13px;

  min-width: 0;

  color: inherit;
  text-decoration: none;
}


.brand-mark {
  display: grid;

  width: 46px;
  height: 46px;

  flex: 0 0 auto;

  place-items: center;

  border-radius: 15px;

  background: var(--primary);
  color: var(--primary-foreground);

  box-shadow:
    0 8px 22px
    color-mix(
      in srgb,
      var(--primary) 24%,
      transparent
    );

  font-size: 1.2rem;
  font-weight: 760;
}


.brand-lockup > span:last-child {
  min-width: 0;
}


.brand-lockup strong,
.brand-lockup small {
  display: block;
}


.brand-lockup strong {
  color: var(--foreground);

  font-size: 1.05rem;
  font-weight: 700;

  letter-spacing: -0.02em;
}


.brand-lockup small {
  margin-top: 3px;

  color: var(--muted-foreground);

  font-size: .8rem;

  white-space: nowrap;
}


/* =========================================================
   Header actions
   ========================================================= */

.header-actions {
  display: flex;
  align-items: center;

  flex: 0 0 auto;

  gap: 10px;
}


.header-link,
.icon-button {
  height: 38px;

  border: 1px solid var(--border);
  border-radius: 12px;

  background:
    color-mix(
      in srgb,
      var(--card) 88%,
      transparent
    );

  color: var(--foreground);

  transition:
    transform 160ms ease,
    background-color 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease;
}


.header-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  min-width: 64px;

  padding: 0 12px;

  text-decoration: none;

  font-size: .75rem;
  font-weight: 650;
}


.icon-button {
  width: 38px;

  padding: 0;

  cursor: pointer;
}


.header-link:hover,
.icon-button:hover {
  transform: translateY(-1px);

  border-color:
    color-mix(
      in srgb,
      var(--primary) 38%,
      var(--border)
    );

  background:
    color-mix(
      in srgb,
      var(--card) 82%,
      var(--accent)
    );
}


.theme-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  width: auto;
  min-width: 76px;

  gap: 7px;
  padding: 0 11px;
}


#themeIcon {
  font-size: 14px;
  line-height: 1;
}


#themeLabel {
  font-size: 12px;
  font-weight: 650;

  white-space: nowrap;
}


ivan-account-bar {
  display: block;
  flex: 0 0 auto;
}


/* =========================================================
   Hero
   ========================================================= */

.hero-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;

  gap: 28px;

  margin: 0 0 20px;
}


.hero-row > div:first-child {
  max-width: 760px;
}


.eyebrow {
  display: inline-block;

  color: var(--primary);

  font-size: .7rem;
  font-weight: 800;

  letter-spacing: .13em;
}


.hero-row h1 {
  margin: 5px 0 5px;

  color: var(--foreground);

  font-size:
    clamp(
      2rem,
      4vw,
      3.6rem
    );

  line-height: 1;

  letter-spacing: -0.055em;
}


.hero-row p {
  max-width: 720px;

  margin: 0;

  color: var(--muted-foreground);

  font-size: .86rem;
  line-height: 1.65;
}


/* =========================================================
   Timer card
   ========================================================= */

.time-card {
  min-width: 150px;

  padding: 13px 16px;

  border: 1px solid var(--border);
  border-radius: 18px;

  background:
    color-mix(
      in srgb,
      var(--card) 88%,
      transparent
    );

  box-shadow:
    0 10px 30px
    rgba(24, 47, 82, .06);

  text-align: right;
}


.time-card span,
.time-card small {
  display: block;

  color: var(--muted-foreground);

  font-size: .72rem;
}


.time-card strong {
  display: inline-block;

  margin: 2px 0;

  color: var(--foreground);

  font-size: 1.65rem;
  font-weight: 750;

  line-height: 1;

  font-variant-numeric: tabular-nums;
  letter-spacing: -.035em;
}


/* =========================================================
   Main layout
   ========================================================= */

.game-layout {
  display: grid;

  grid-template-columns:
    minmax(0, 1fr)
    330px;

  gap: 18px;

  align-items: start;
}


.side-column {
  display: grid;

  gap: 18px;
}


/* =========================================================
   Cards
   ========================================================= */

.card {
  border: 1px solid var(--border);
  border-radius: 25px;

  background:
    color-mix(
      in srgb,
      var(--card) 94%,
      transparent
    );

  box-shadow:
    0 16px 48px
    rgba(20, 44, 79, .08);

  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}


.board-card {
  padding: 18px;
}


.settings-card,
.records-card {
  padding: 18px;
}


/* =========================================================
   Game toolbar
   ========================================================= */

.game-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;

  gap: 20px;

  min-height: 46px;

  margin-bottom: 14px;
}


.status-group {
  display: flex;
  align-items: center;

  gap: 10px;

  min-width: 0;
}


.phase-badge {
  flex: 0 0 auto;

  padding: 6px 10px;

  border-radius: 999px;

  background: var(--secondary);
  color: var(--secondary-foreground);

  font-size: .74rem;
  font-weight: 760;
}


#phaseText {
  min-width: 0;

  overflow: hidden;

  color: var(--muted-foreground);

  font-size: .78rem;

  text-overflow: ellipsis;
  white-space: nowrap;
}


.game-actions {
  display: flex;
  align-items: center;

  flex: 0 0 auto;

  gap: 10px;
}


/* =========================================================
   Buttons
   ========================================================= */

.button {
  min-height: 42px;

  border: 1px solid transparent;
  border-radius: 13px;

  padding: 0 17px;

  cursor: pointer;

  font-size: .78rem;
  font-weight: 720;

  transition:
    transform .15s ease,
    box-shadow .15s ease,
    border-color .15s ease,
    opacity .15s ease;
}


.button:hover:not(:disabled) {
  transform: translateY(-1px);
}


.button:disabled {
  cursor: not-allowed;
  opacity: .52;
}


.button.primary {
  background: var(--primary);
  color: var(--primary-foreground);

  box-shadow:
    0 8px 22px
    color-mix(
      in srgb,
      var(--primary) 22%,
      transparent
    );
}


.button.ghost {
  border-color: var(--border);

  background: transparent;
  color: var(--muted-foreground);
}


.button.ghost:hover:not(:disabled) {
  color: var(--foreground);

  border-color:
    color-mix(
      in srgb,
      var(--primary) 28%,
      var(--border)
    );
}


/* =========================================================
   Board
   ========================================================= */

.board-frame {
  position: relative;

  display: grid;

  min-height: 540px;

  place-items: center;

  overflow: hidden;

  border: 1px solid
    color-mix(
      in srgb,
      var(--border) 82%,
      var(--foreground)
    );

  border-radius: 17px;

  padding:
    clamp(
      16px,
      3vw,
      34px
    );

  background:
    radial-gradient(
      circle at 35% 30%,
      color-mix(
        in srgb,
        var(--primary) 5%,
        transparent
      ),
      transparent 42%
    ),
    color-mix(
      in srgb,
      var(--muted) 58%,
      var(--card)
    );
}


/* =========================================================
   Schulte grid
   ========================================================= */

.schulte-grid {
  display: grid;

  width:
    min(
      100%,
      650px
    );

  aspect-ratio: 1 / 1;

  gap:
    clamp(
      4px,
      .75vw,
      10px
    );
}


.schulte-cell {
  display: grid;

  min-width: 0;
  min-height: 0;

  place-items: center;

  border: 1px solid var(--border);

  border-radius:
    clamp(
      7px,
      1vw,
      14px
    );

  padding: 0;

  background:
    color-mix(
      in srgb,
      var(--card) 96%,
      var(--background)
    );

  color: var(--foreground);

  cursor: pointer;
  user-select: none;

  font-size:
    clamp(
      .78rem,
      2vw,
      1.55rem
    );

  font-weight: 780;

  font-variant-numeric: tabular-nums;

  transition:
    transform 80ms ease,
    box-shadow 120ms ease,
    background-color 120ms ease,
    border-color 120ms ease,
    color 120ms ease;
}


.schulte-cell:hover:not(:disabled) {
  transform: translateY(-1px);

  border-color:
    color-mix(
      in srgb,
      var(--primary) 52%,
      var(--border)
    );

  box-shadow:
    0 7px 18px
    color-mix(
      in srgb,
      var(--primary) 9%,
      transparent
    );
}


.schulte-cell:active:not(:disabled) {
  transform: scale(.97);
}


.schulte-grid.concealed
.schulte-cell {
  color: transparent;
}


.schulte-cell.correct,
.schulte-cell.correct:disabled {
  border-color:
    color-mix(
      in srgb,
      var(--success) 62%,
      var(--border)
    );

  background: var(--success-soft);

  color: var(--success);

  opacity: 1;
}


.schulte-cell.wrong {
  transform: scale(.96);

  border-color: var(--destructive);

  background:
    color-mix(
      in srgb,
      var(--destructive) 16%,
      var(--card)
    );

  color: var(--destructive);
}


/* =========================================================
   Countdown
   ========================================================= */

.countdown-overlay {
  position: absolute;
  inset: 0;

  z-index: 20;

  display: flex;
  align-items: center;
  justify-content: center;

  border-radius: inherit;

  background:
    color-mix(
      in srgb,
      var(--background) 20%,
      transparent
    );

  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);

  pointer-events: none;
}


.countdown-number {
  display: flex;

  width: 120px;
  height: 120px;

  align-items: center;
  justify-content: center;

  border-radius: 28px;

  background: rgba(20, 20, 20, .88);
  color: #fff;

  box-shadow:
    0 18px 50px
    rgba(0, 0, 0, .22);

  font-size: 64px;
  font-weight: 800;

  line-height: 1;

  animation:
    countdownPop .55s ease;
}


@keyframes countdownPop {

  0% {
    transform: scale(.75);
    opacity: 0;
  }

  25% {
    transform: scale(1.08);
    opacity: 1;
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }

}


/* =========================================================
   Result
   ========================================================= */

.result-panel {
  display: grid;

  grid-template-columns:
    repeat(
      3,
      minmax(0, 1fr)
    );

  gap: 10px;

  margin-top: 14px;
}


.result-panel > div {
  min-width: 0;

  border: 1px solid var(--border);
  border-radius: 15px;

  padding: 12px 14px;

  background:
    color-mix(
      in srgb,
      var(--success-soft) 34%,
      var(--card)
    );
}


.result-panel span,
.result-panel strong {
  display: block;
}


.result-panel span {
  color: var(--muted-foreground);

  font-size: .7rem;
}


.result-panel strong {
  margin-top: 4px;

  color: var(--foreground);

  font-size: 1rem;

  font-variant-numeric: tabular-nums;
}


/* =========================================================
   Side cards
   ========================================================= */

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;

  gap: 12px;

  margin-bottom: 15px;
}


.section-heading span {
  color: var(--muted-foreground);

  font-size: .66rem;
  font-weight: 800;

  letter-spacing: .12em;
}


.section-heading h2 {
  margin: 3px 0 0;

  color: var(--foreground);

  font-size: 1.05rem;
}


/* records 内部的小排行榜链接 */

.section-heading .text-link {
  flex: 0 0 auto;

  color: var(--muted-foreground);

  font-size: .72rem;
  font-weight: 650;

  text-decoration: none;
}


.section-heading .text-link:hover {
  color: var(--foreground);
}


/* =========================================================
   Field
   ========================================================= */

.field {
  display: block;
}


.field > span,
.field > small {
  display: block;
}


.field > span {
  margin-bottom: 7px;

  color: var(--foreground);

  font-size: .76rem;
  font-weight: 720;
}


.field input {
  width: 100%;
  height: 42px;

  border: 1px solid var(--input);
  border-radius: 12px;

  padding: 0 12px;

  outline: none;

  background:
    color-mix(
      in srgb,
      var(--background) 76%,
      var(--card)
    );

  color: var(--foreground);

  transition:
    border-color .15s ease,
    box-shadow .15s ease,
    background-color .15s ease;
}


.field input:focus {
  border-color: var(--ring);

  box-shadow:
    0 0 0 3px
    color-mix(
      in srgb,
      var(--ring) 16%,
      transparent
    );
}


.field > small {
  margin-top: 7px;

  color: var(--muted-foreground);

  font-size: .68rem;
  line-height: 1.5;
}


/* =========================================================
   Player
   ========================================================= */

.player-row {
  display: flex;
  align-items: center;
  justify-content: space-between;

  gap: 10px;

  margin-top: 16px;
  padding-top: 14px;

  border-top: 1px solid var(--border);

  font-size: .76rem;
}


.player-row span {
  color: var(--muted-foreground);
}


.player-row strong {
  max-width: 190px;

  overflow: hidden;

  color: var(--foreground);

  text-overflow: ellipsis;
  white-space: nowrap;
}


/* =========================================================
   Records
   ========================================================= */

.records-list {
  display: grid;

  gap: 9px;

  max-height: 380px;

  overflow-y: auto;

  padding-right: 2px;
}


.record-item {
  display: grid;

  grid-template-columns:
    auto
    minmax(0, 1fr)
    auto;

  align-items: center;

  gap: 10px;

  border: 1px solid var(--border);
  border-radius: 13px;

  padding: 10px 11px;

  background:
    color-mix(
      in srgb,
      var(--muted) 45%,
      transparent
    );
}


.record-time {
  min-width: 70px;

  color: var(--primary);

  font-size: .82rem;
  font-weight: 800;

  font-variant-numeric: tabular-nums;
}


.record-main {
  min-width: 0;
}


.record-main strong,
.record-main small,
.record-side strong,
.record-side small {
  display: block;
}


.record-main strong {
  overflow: hidden;

  color: var(--foreground);

  font-size: .75rem;

  text-overflow: ellipsis;
  white-space: nowrap;
}


.record-main small,
.record-side small {
  margin-top: 2px;

  color: var(--muted-foreground);

  font-size: .64rem;
}


.record-side {
  text-align: right;
}


.record-side strong {
  color: var(--foreground);

  font-size: .74rem;
}


/* =========================================================
   Empty
   ========================================================= */

.empty-state {
  margin: 12px 0;

  padding: 14px 4px;

  color: var(--muted-foreground);

  font-size: .76rem;
  text-align: center;
}


/* =========================================================
   Footer
   ========================================================= */

.page-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;

  gap: 20px;

  margin-top: 18px;
  padding: 10px 3px 0;

  color: var(--muted-foreground);

  font-size: .76rem;
}


.page-footer a {
  color: var(--muted-foreground);

  text-decoration: none;
}


.page-footer a:hover {
  color: var(--foreground);
}


/* =========================================================
   Paper
   ========================================================= */

:root[data-theme="paper"]
.card,
:root[data-theme="paper"]
.time-card {
  box-shadow:
    0 16px 44px
    rgba(70, 52, 37, .07);
}


:root[data-theme="paper"]
.schulte-cell {
  box-shadow:
    inset 0 0 0 1px
    rgba(255, 255, 255, .15);
}


/* =========================================================
   Night
   ========================================================= */

:root[data-theme="night"]
.card,
:root[data-theme="night"]
.time-card {
  box-shadow:
    0 22px 60px
    rgba(0, 0, 0, .28);
}


:root[data-theme="night"]
.board-frame {
  border-color:
    color-mix(
      in srgb,
      var(--border) 88%,
      #fff
    );

  background:
    radial-gradient(
      circle at 40% 28%,
      rgba(210, 160, 110, .045),
      transparent 45%
    ),
    #0e1115;
}


:root[data-theme="night"]
.schulte-cell {
  background:
    color-mix(
      in srgb,
      var(--card) 95%,
      #0e1115
    );
}


/* =========================================================
   Tablet
   ========================================================= */

@media (max-width: 980px) {

  .game-layout {
    grid-template-columns:
      minmax(0, 1fr)
      300px;
  }

}


@media (max-width: 860px) {

  .game-layout {
    grid-template-columns: 1fr;
  }


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


  .board-frame {
    min-height: auto;
  }

}


/* =========================================================
   Mobile
   ========================================================= */

@media (max-width: 720px) {

  .page-wrap {
    width: 100%;

    padding:
      16px
      14px
      20px;
  }


  /* 顶栏和 Ball Attention 一样改为两行 */

  .app-header {
    display: grid;

    grid-template-columns:
      1fr
      auto;

    align-items: center;

    gap: 14px 10px;

    width: 100%;

    margin-bottom: 24px;
  }


  .brand-lockup {
    grid-column:
      1 / -1;

    width: 100%;
  }


  .brand-lockup > span:last-child {
    flex: 1;
  }


  .brand-lockup strong,
  .brand-lockup small {
    width: 100%;
  }


  .header-actions {
    grid-column:
      1 / -1;

    display: flex;

    width: 100%;

    justify-content: flex-end;

    gap: 8px;
  }


  .hero-row {
    display: block;

    width: 100%;

    margin-bottom: 18px;
  }


  .hero-row > div:first-child {
    width: 100%;
    max-width: none;
  }


  .hero-row h1 {
    width: 100%;

    font-size:
      clamp(
        2.15rem,
        12vw,
        3.2rem
      );
  }


  .hero-row p {
    width: 100%;
    max-width: none;

    margin-top: 7px;

    line-height: 1.5;
  }


  .time-card {
    width: 100%;

    margin-top: 14px;

    text-align: left;
  }


  .game-layout {
    width: 100%;

    grid-template-columns: 1fr;
  }


  .side-column {
    width: 100%;

    grid-template-columns: 1fr;
  }


  .board-card {
    padding: 14px;
  }


  .board-frame {
    min-height: auto;

    padding: 12px;
  }


  .game-toolbar {
    align-items: flex-start;
  }


  #phaseText {
    display: none;
  }


  .result-panel {
    grid-template-columns: 1fr;
  }


  .page-footer {
    align-items: flex-start;

    flex-direction: column;

    gap: 8px;
  }

}


/* =========================================================
   Small mobile
   ========================================================= */

@media (max-width: 520px) {

  .brand-mark {
    width: 42px;
    height: 42px;

    border-radius: 13px;
  }


  .brand-lockup strong {
    font-size: .94rem;
  }


  .brand-lockup small {
    font-size: .72rem;
  }


  .header-actions {
    overflow-x: auto;
  }


  .header-link {
    min-width: 58px;

    padding: 0 10px;
  }


  .theme-button {
    min-width: 70px;

    padding: 0 9px;
  }


  .game-toolbar {
    gap: 10px;
  }


  .button {
    min-height: 38px;

    padding: 0 13px;
  }


  .record-item {
    grid-template-columns:
      minmax(64px, auto)
      minmax(0, 1fr);
  }


  .record-side {
    grid-column: 2;

    text-align: left;
  }

}