:root {
  color-scheme: light;
  --bg: #f3f4f5;
  --surface: #ffffff;
  --surface-soft: #f7f8f9;
  --ink: #1f2328;
  --muted: #687076;
  --line: #d8dee4;
  --accent: #2f6f73;
  --accent-dark: #24575a;
  --blue: #4d6379;
  --shadow: 0 8px 24px rgba(31, 35, 40, 0.08);
  --radius: 6px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  height: 100vh;
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  background: var(--bg);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  width: min(1180px, calc(100% - 20px));
  height: calc(100vh - 20px);
  margin: 10px auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 18px 14px;
  border-right: 1px solid var(--line);
  background: #f6f8fa;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 7px;
  color: #ffffff;
  background: var(--accent);
  font-weight: 780;
}

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

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.76rem;
}

.tool-nav {
  display: grid;
  gap: 8px;
}

.nav-label {
  grid-column: 1 / -1;
  margin: 0 0 2px 4px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 46px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 7px;
  color: var(--muted);
  background: transparent;
  font-weight: 650;
  text-align: left;
}

.nav-item:hover {
  color: var(--ink);
  background: var(--surface-soft);
}

.nav-item.active {
  border-color: #c8d7d9;
  color: var(--accent-dark);
  background: #e9f1f2;
}

.nav-item svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
}

.is-hidden {
  display: none !important;
}

.sidebar-note {
  margin-top: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

.sidebar-note span,
.page-note,
.text-toolbar,
.history-box li {
  color: var(--muted);
}

.sidebar-note span {
  display: block;
  margin-bottom: 4px;
  font-size: 0.78rem;
}

.sidebar-note strong {
  display: block;
  font-size: 0.9rem;
}

.content-area {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  padding: clamp(14px, 2.5vh, 24px) clamp(18px, 3vw, 30px);
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: clamp(12px, 2vh, 20px);
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent-dark);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.65rem, 4vw, 2.45rem);
  line-height: 1.1;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 1.12rem;
  letter-spacing: 0;
}

.page-note {
  margin: 6px 0 0;
  font-size: 0.94rem;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface);
  font-size: 0.88rem;
  font-weight: 650;
  white-space: nowrap;
}

.status-pill span {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--accent);
}

.tool-panel {
  display: none;
  width: min(900px, 100%);
  max-height: 100%;
  padding: clamp(14px, 2.4vh, 22px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: none;
}

.tool-panel.active {
  display: block;
}

#calculator.tool-panel.active {
  display: grid;
}

.tool-intro {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: clamp(12px, 2vh, 18px);
}

#calculator .tool-intro {
  grid-column: 1 / -1;
}

.ghost-button {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  background: var(--surface-soft);
  font-size: 0.9rem;
  font-weight: 650;
}

.ghost-button:hover {
  border-color: rgba(25, 114, 120, 0.34);
}

#calculator {
  display: none;
  grid-template-columns: minmax(280px, 390px) minmax(220px, 1fr);
  gap: 18px;
  align-items: start;
}

.calculator {
  display: grid;
  gap: 10px;
  width: min(390px, 100%);
}

.calc-display {
  display: block;
  min-height: 64px;
  padding: 12px 16px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: #f8fafb;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: clamp(1.45rem, 5vh, 2.45rem);
  font-weight: 600;
  line-height: 1.2;
  text-align: right;
  white-space: nowrap;
}

.calc-keys {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-auto-rows: clamp(46px, 8vh, 64px);
  gap: 7px;
}

.calc-keys button {
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  background: #f9fbfc;
  font-size: 1.08rem;
  font-weight: 650;
}

.calc-keys button:hover {
  background: var(--surface-soft);
}

.calc-keys .operator {
  color: #ffffff;
  border-color: var(--blue);
  background: var(--blue);
}

.calc-keys .equals {
  color: #ffffff;
  border-color: var(--accent);
  background: var(--accent);
}

.calc-keys .wide {
  grid-column: span 2;
}

.text-input {
  display: block;
  width: 100%;
  height: clamp(190px, 39vh, 310px);
  min-height: 0;
  padding: 18px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: #f8fafb;
  font-size: 1rem;
  line-height: 1.6;
  outline: none;
}

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

.form-field {
  display: grid;
  gap: 7px;
}

.form-field span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 650;
}

.form-field input,
.form-field select {
  width: 100%;
  min-height: 42px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: #f8fafb;
}

.form-field input:focus,
.form-field select:focus {
  border-color: rgba(25, 114, 120, 0.56);
  box-shadow: 0 0 0 3px rgba(25, 114, 120, 0.12);
  outline: none;
}

.conversion-result {
  display: grid;
  gap: 8px;
  margin-top: 18px;
  padding: 16px;
  border: 1px solid #c8d7d9;
  border-radius: var(--radius);
  background: #f3f8f8;
}

.conversion-result span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 650;
}

.conversion-result strong {
  overflow-wrap: anywhere;
  font-size: clamp(1.1rem, 3vw, 1.55rem);
}

.common-conversions {
  margin-top: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8fafb;
}

.common-conversions h3 {
  margin: 0 0 10px;
  font-size: 0.95rem;
}

.common-conversions div {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.common-conversions button {
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: #ffffff;
  font-size: 0.86rem;
  text-align: left;
}

.common-conversions button:hover {
  background: var(--surface-soft);
}

.arcade-screen {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: block;
  background: #000000;
  color: #f6f7f9;
}

.arcade-main {
  display: flex;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  background: #090a11;
}

.arcade-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 70px;
  padding: 16px 26px 8px;
  background: #090a11;
}

.arcade-topbar p,
.player-header p {
  margin: 0 0 4px;
  color: rgba(255, 255, 255, 0.56);
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
}

.arcade-topbar h2,
.player-header h3 {
  margin: 0;
  color: #ffffff;
  letter-spacing: 0;
}

.arcade-actions {
  display: flex;
  align-items: end;
  gap: 10px;
}

.arcade-search {
  display: grid;
  gap: 6px;
}

.arcade-search span {
  color: rgba(255, 255, 255, 0.48);
  font-size: 0.72rem;
  font-weight: 700;
}

.arcade-search input {
  width: min(280px, 42vw);
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid #26283a;
  border-radius: 8px;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
  outline: none;
}

.arcade-search input:focus {
  border-color: rgba(255, 255, 255, 0.34);
}

.arcade-close,
.player-header button {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius);
  color: rgba(255, 255, 255, 0.72);
  background: rgba(255, 255, 255, 0.06);
  font-size: 0.88rem;
}

.arcade-close:hover,
.player-header button:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.12);
}

.arcade-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-height: 0;
  flex: 1;
  padding: 0 26px 24px;
  overflow: hidden;
}

.game-browser {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 12px;
  min-height: 0;
}

.arcade-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.arcade-section-head h3 {
  margin: 0;
  color: #f6f7f9;
  font-size: 1.15rem;
}

.arcade-section-head span {
  color: rgba(255, 255, 255, 0.56);
  font-size: 0.9rem;
  font-weight: 700;
}

.category-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.category-tabs button {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid #26283a;
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.68);
  background: rgba(255, 255, 255, 0.06);
  white-space: nowrap;
}

.category-tabs button.active {
  border-color: #2f6f73;
  color: #ffffff;
  background: #2f6f73;
}

.game-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(154px, 1fr));
  grid-auto-rows: 118px;
  gap: 12px;
  align-content: start;
  overflow: auto;
  padding: 0 4px 18px 0;
}

.game-card {
  position: relative;
  display: block;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 8px;
  color: #ffffff;
  background: #12131c;
  text-align: left;
}

.game-card:hover {
  transform: translateY(-1px);
  filter: brightness(1.08);
}

.game-card img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #181818;
}

.game-card div {
  position: absolute;
  inset: auto 0 0;
  display: grid;
  gap: 3px;
  padding: 34px 12px 10px;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.78));
}

.game-card h3 {
  margin: 0;
  font-size: 1rem;
}

.game-card p {
  margin: 0;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.82rem;
}

.game-card.hero {
  grid-column: span 2;
  grid-row: span 2;
}

.game-card.wide {
  grid-column: span 2;
}

.game-card.hero h3 {
  font-size: 2.05rem;
  letter-spacing: 0;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.6);
}

.game-card.live::before,
.game-card.placeholder::before {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 1;
  min-height: 26px;
  padding: 4px 10px;
  border-radius: 7px;
  color: #ffffff;
  font-size: 0.8rem;
  font-weight: 800;
}

.game-card.live::before {
  content: "Play";
  background: #2f6f73;
}

.game-card.placeholder::before {
  content: "Soon";
  background: rgba(0, 0, 0, 0.58);
}

.empty-games {
  margin: 0;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.58);
  background: #101010;
}

.game-player {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  overflow: hidden;
  background: #050505;
}

.player-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.player-header div:last-child {
  display: flex;
  gap: 8px;
}

.game-player iframe {
  width: 100%;
  height: 100%;
  min-height: 420px;
  border: 0;
  background: #000000;
}

.history-box {
  min-height: 250px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8fafb;
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.history-header h3 {
  margin: 0;
  font-size: 0.95rem;
}

.history-header button {
  border: 0;
  color: var(--muted);
  background: transparent;
  font-size: 0.82rem;
}

.history-box ol {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 20px;
}

.history-box li {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.86rem;
  line-height: 1.45;
}

.text-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
  font-size: 0.82rem;
}

.text-input:focus {
  border-color: rgba(25, 114, 120, 0.56);
  box-shadow: 0 0 0 3px rgba(25, 114, 120, 0.12);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.stats-grid article {
  min-height: 78px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

.stats-grid span {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 650;
}

.stats-grid strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: clamp(1.35rem, 4vw, 2rem);
}

@media (max-width: 760px) {
  body {
    height: auto;
    min-height: 100vh;
    overflow: auto;
  }

  .app-shell {
    grid-template-columns: 1fr;
    width: min(100% - 20px, 760px);
    height: auto;
    min-height: calc(100vh - 20px);
    margin: 10px auto;
  }

  .sidebar {
    gap: 14px;
    padding: 14px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .tool-nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .nav-item {
    justify-content: center;
  }

  .content-area {
    padding: 16px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .status-pill {
    width: fit-content;
  }

  .tool-panel {
    width: 100%;
    overflow: visible;
  }

  #calculator.active {
    grid-template-columns: 1fr;
  }

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

  .converter-grid,
  .common-conversions div {
    grid-template-columns: 1fr;
  }

  .arcade-topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .arcade-actions {
    align-items: stretch;
  }

  .arcade-search,
  .arcade-search input {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .brand {
    justify-content: center;
  }

  .nav-item {
    gap: 8px;
    padding-inline: 8px;
    font-size: 0.9rem;
  }

  .nav-item svg {
    display: none;
  }

  .tool-intro {
    align-items: flex-start;
    flex-direction: column;
  }

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