/* ==========================================================================
   Theme tokens
   ========================================================================== */

:root {
  --background: #f0efe9;
  --surface: #ffffff;
  --surface-revealed: #fbfaf5;
  --text: #1e1e1e;
  --muted: #6b6b64;
  --accent: #1c7a3c;
  --accent-dim: #3f8f5c;
  --border: #d8d6cc;
  --border-faded: rgba(216, 214, 204, 0.35);

  --space-1: 0.5rem;
  --space-2: 1rem;
  --space-3: 1.75rem;
  --space-4: 3rem;
  --space-5: 4.5rem;

  --bubble-bg: #10120f;
  --bubble-text: #f0efe9;
}

[data-theme="dark"] {
  --background: #10120f;
  --surface: #000000;
  --surface-revealed: #161712;
  --text: #cfd0c9;
  --muted: #7c7d75;
  --accent: #3ecf6b;
  --accent-dim: #2e9e51;
  --border: #2a2c26;
  --border-faded: rgba(42, 44, 38, 0.35);

  --bubble-bg: #f0efe9;
  --bubble-text: #1e1e1e;
}

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

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: clamp(16px, 6px + 0.55vw, 21px);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background-color: var(--background);
  color: var(--text);
  font-family: "Space Mono", "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 1rem;
  line-height: 1.65;
  overflow-x: hidden;
}

img {
  max-width: 100%;
  display: block;
}

p {
  margin: 0 0 var(--space-2) 0;
}

/* ==========================================================================
   Typography
   ========================================================================== */

h1,
h2 {
  font-family: inherit;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0;
}

.name {
  font-size: 1.5rem;
  margin-top: var(--space-2);
}

.title {
  color: var(--muted);
  font-size: 0.95rem;
  margin-top: 0.35rem;
}

.tagline {
  margin-top: var(--space-2);
  max-width: 56ch;
}

.location {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 0.35rem;
}

.section-heading {
  display: flex;
  align-items: baseline;
  overflow: hidden;
  white-space: nowrap;
  font-size: 1rem;
  color: var(--text);
  margin-bottom: var(--space-2);
}

.section-heading::after {
  content: " -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------";
  color: var(--border);
  flex: 1 1 auto;
  overflow: hidden;
  white-space: pre;
  margin-left: 0.6em;
}

/* ==========================================================================
   Layout
   ========================================================================== */

main {
  max-width: 64ch;
  margin: 0 auto;
  padding: var(--space-4) var(--space-2) var(--space-5) var(--space-2);
}

@media (min-width: 900px) {
  main {
    max-width: 85ch;
  }
}

section {
  margin-top: var(--space-4);
}

section:first-of-type {
  margin-top: var(--space-4);
}

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

.site-header {
  padding-bottom: var(--space-3);
}

.header-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-2);
}

[hidden] {
  display: none !important;
}

.avatar {
  width: 84px;
  height: auto;
}

.avatar.ms-shrunk {
  width: auto;
  height: 28px;
}

.avatar-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.avatar-bubble {
  position: relative;
  background: var(--bubble-bg);
  color: var(--bubble-text);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 400;
  line-height: 1.45;
  padding: 0.5em 0.75em;
  border-radius: 0;
  max-width: min(48ch, 100%);
  white-space: normal;
  transform: translateY(8px);
}

.avatar-bubble::before {
  content: "";
  position: absolute;
  left: -8px;
  top: 50%;
  transform: translateY(-50%);
  border-width: 6px 8px 6px 0;
  border-style: solid;
  border-color: transparent var(--bubble-bg) transparent transparent;
}

.bubble-bullet {
  color: var(--accent);
}

.avatar-bubble.ms-mode {
  flex: 0 1 auto;
  min-width: 0;
  align-self: center;
  font-size: 0.65rem;
  line-height: 1.3;
  padding: 0.3em 0.6em;
  max-width: 36ch;
  transform: none;
}

.avatar-bubble.ms-mode .bubble-text {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.bubble-short {
  display: none;
}

.avatar-bubble.ms-mode .bubble-full {
  display: none;
}

.avatar-bubble.ms-mode .bubble-short {
  display: inline;
}

.header-links {
  margin-top: var(--space-2);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-3);
}

/* ==========================================================================
   Header buttons (play, theme toggle)
   ========================================================================== */

.header-button {
  appearance: none;
  background: none;
  border: none;
  padding: 0.2rem 0.1rem;
  margin-top: 0.15rem;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
}

.header-button:hover {
  color: var(--accent);
}

.header-button:focus-visible {
  outline: 1px dashed var(--accent);
  outline-offset: 3px;
}

.header-buttons {
  display: flex;
  gap: var(--space-2);
  margin-left: auto;
}

/* ==========================================================================
   Links
   ========================================================================== */

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: var(--accent-dim);
  text-decoration: underline;
}

a:focus-visible {
  outline: 1px dashed var(--accent);
  outline-offset: 2px;
}

a[aria-disabled="true"] {
  color: var(--muted);
  cursor: default;
  pointer-events: none;
}

/* ==========================================================================
    Highlight
    ========================================================================== */

em {
  font-style: normal;
  text-shadow: 0 0 5px #777777;
}

[data-theme="dark"] em {
  color: #ffffff;
  text-shadow: 0 0 5px #999999;
}

/* ==========================================================================
   Sections / entries
   ========================================================================== */

.entry {
  margin-bottom: var(--space-3);
}

.entry:last-child {
  margin-bottom: 0;
}

.entry-compact {
  margin-bottom: var(--space-2);
}

.entry-title {
  font-weight: 700;
  margin-bottom: 0.15rem;
}

.entry-meta {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: var(--space-2);
}

.entry-description {
  margin-bottom: var(--space-2);
  max-width: 62ch;
}

.entry-list {
  margin: 0 0 var(--space-2) 0;
  padding-left: 1.1em;
  max-width: 62ch;
  color: var(--text);
}

.entry-list li {
  margin-bottom: 0.35rem;
}

.entry-list li::marker {
  color: var(--accent);
}

.entry-tech-label {
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 0.2rem;
}

.entry-tech {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 0;
}

.entry-links {
  margin-top: 0.5rem;
  display: flex;
  gap: var(--space-2);
}

/* ==========================================================================
   Skills
   ========================================================================== */

.skill-group {
  margin-bottom: var(--space-2);
}

.skill-group-title {
  font-weight: 700;
  margin-bottom: 0.15rem;
}

.skill-list {
  color: var(--muted);
}

/* ==========================================================================
    Languages
    ========================================================================== */

.lang-item {
  margin-bottom: 0.35rem;
}

.lang-name {
  font-weight: 700;
}

.lang-level {
  color: var(--muted);
}

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

.site-footer {
  margin-top: var(--space-5);
  color: var(--muted);
  font-size: 0.85rem;
}

.site-footer p {
  margin: 0 0 0.25rem 0;
}

/* ==========================================================================
   Minesweeper
   ========================================================================== */

.minesweeper-section {
  margin-top: 0;
}

.ms-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: var(--space-2);
}

.ms-button-group {
  display: flex;
  gap: 0.25rem;
  align-items: center;
}

.ms-status {
  color: var(--muted);
  font-size: 0.9rem;
}

.ms-status.win {
  color: var(--accent);
  font-weight: 700;
  font-size: 1rem;
}

.ms-status.lose {
  color: #e24b4a;
  font-weight: 700;
  font-size: 1rem;
}

.ms-replay {
  font-size: 0.85rem;
  padding: 0.2rem 0.1rem;
  margin-top: 0.15rem;
  color: var(--muted);
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  background: none;
  border: none;
}

.ms-replay:hover {
  color: var(--accent);
}

.ms-board {
  display: grid;
  gap: 0;
  border: 1px solid var(--border);
  border-top: 1px solid var(--border);
  border-left: 1px solid var(--border);
  width: 100%;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
}

.ms-cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-revealed);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  line-height: 1;
  touch-action: manipulation;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
  min-height: 0;
}

.ms-cell.revealed {
  border-right-color: var(--border-faded);
  border-bottom-color: var(--border-faded);
}

.ms-cell.hidden-cell {
  background: var(--background);
}

.ms-cell.hidden-cell:hover {
  background: var(--border);
}

.ms-cell.flag {
  color: #e24b4a;
}

[data-theme="dark"] .ms-cell.flag {
  color: #ff6b6a;
}

.ms-cell.mine img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  overflow: hidden;
}

.ms-cell.mine.exploded {
  background: #e24b4a;
}

.ms-board.win .ms-cell.mine {
  background: var(--accent);
}

.ms-cell.n1 { color: #6fa8dc; }
.ms-cell.n2 { color: var(--accent); }
.ms-cell.n3 { color: #e08a2e; }
.ms-cell.n4 { color: #9b8fd6; }
.ms-cell.n5 { color: #b5705a; }
.ms-cell.n6 { color: #5fc4c4; }
.ms-cell.n7 { color: var(--text); }
.ms-cell.n8 { color: var(--muted); }

.ms-hint {
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: var(--space-2);
  margin-bottom: 0;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 900px) {
  main {
    padding-left: 20px;
    padding-right: 20px;
  }
}

@media (max-width: 480px) {
  main {
    padding-left: 16px;
    padding-right: 16px;
    padding-top: var(--space-3);
  }

  .name {
    font-size: 1.3rem;
  }

  .avatar {
    width: 64px;
    margin-top: 1.5rem;
  }

  .avatar.ms-shrunk {
    margin-top: 0.35rem;
  }

  .header-top {
    position: relative;
    align-items: flex-start;
  }

  .header-buttons {
    position: absolute;
    top: 0.15rem;
    right: 0;
  }

  .avatar-row {
    align-items: flex-start;
  }

  .avatar-bubble {
    flex: 1;
    max-width: none;
    margin-top: 2.8rem;
    transform: none;
  }

  .avatar-bubble::before {
    top: 2.25rem;
    left: -7px;
  }

  .avatar-bubble.ms-mode {
    margin-top: 0;
    max-width: 24ch;
  }

  .avatar-bubble.ms-mode::before {
    top: 50%;
  }

  section {
    margin-top: var(--space-3);
  }
}

/* ==========================================================================
   Accessibility
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}