/* 1. Design tokens */

.lh-player {
  --table: #e9e3d8;
  --ink: #2b2a28;
  --title: #4d473d;
  --muted: #8a7f6c;
  --icon: #7d7466;
  --icon-hover: #4d473d;
  --edge: #d6cebf;
  --focus: rgba(24, 117, 208, 0.35);
  --font: "Nunito", sans-serif;
  --w1: #26436e;
  --w2: #0c447c;
  --w3: #3c3489;
  --w4: #7a3d16;
  --w5: #6b5300;
  --w6: #72243e;
  --white: #fff;
  --blue: #1875d0;
  --blue-edge: #125ca6;
  --radius: 18px;
  --radius-pill: 999px;
  --shadow-card: 0 16px 34px rgba(60, 45, 20, 0.20);
  --bar-h: 44px;
  --base: 32px;
}

html,
body.page-scatter {
  height: 100%;
}

body.page-scatter {
  overflow: hidden;
  margin: 0;
  background: var(--table, #e9e3d8);
}

.lh-player {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  min-height: 100%;
  overflow: hidden;
  background: var(--table);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.25;
}

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

.lh-player button {
  width: auto;
  height: auto;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
  line-height: 1;
  box-shadow: none;
  cursor: pointer;
}

.lh-player button:hover,
.lh-player button:disabled {
  background: transparent;
  color: inherit;
  box-shadow: none;
  transform: none;
}

.lh-player button:focus,
.lh-player a:focus {
  outline: none;
}

.lh-player .lh-home:focus-visible,
.lh-player .lh-icon:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--focus);
}

/* 1b. Black and white mode */

.lh-player.is-mono {
  --table: #fff;
  --ink: #1a1a1a;
  --title: #333;
  --muted: #8c8c8c;
  --icon: #6b6b6b;
  --icon-hover: #1a1a1a;
  --edge: #dcdcdc;
  --focus: rgba(0, 0, 0, 0.3);
  --w1: #1a1a1a;
  --w2: #1a1a1a;
  --w3: #1a1a1a;
  --w4: #1a1a1a;
  --w5: #1a1a1a;
  --w6: #1a1a1a;
  --blue: #1a1a1a;
  --blue-edge: #000;
  --shadow-card: 0 16px 34px rgba(0, 0, 0, 0.16);
}

body.page-scatter.is-mono {
  background: #fff;
}

.lh-player .lh-icon[aria-pressed="true"] {
  color: var(--icon-hover);
}

/* 2. Top bar */

.lh-player .lh-bar {
  position: relative;
  z-index: 4;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  height: var(--bar-h);
  min-height: var(--bar-h);
  padding: 0 6px;
  background: var(--table);
  border-bottom: 1px solid var(--edge);
}

.lh-player .lh-home {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-width: 40px;
  min-height: 40px;
  color: var(--icon);
  text-decoration: none;
}

.lh-player .lh-home:hover {
  color: var(--icon-hover);
  text-decoration: none;
  background: transparent;
}

.lh-player .lh-home svg,
.lh-player .lh-icon svg {
  display: block;
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.lh-player .lh-title {
  margin: 0;
  padding: 0 8px;
  min-width: 0;
  color: var(--title);
  font-family: var(--font);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lh-player .lh-tools {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 0;
}

.lh-player .lh-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-width: 40px;
  min-height: 40px;
  color: var(--icon);
}

.lh-player .lh-icon:hover {
  color: var(--icon-hover);
}

.lh-player .lh-icon:disabled {
  opacity: 0.35;
  color: var(--icon);
  cursor: default;
}

.lh-player .lh-icon:disabled:hover {
  color: var(--icon);
}

.lh-player .lh-icon[hidden] {
  display: none;
}

.lh-player .lh-type {
  width: 44px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0;
}

.lh-player [data-tip] {
  position: relative;
}

.lh-player [data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  top: calc(100% - 2px);
  left: 50%;
  padding: 4px 7px;
  border-radius: 4px;
  background: #4d473d;
  color: #fff;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, 4px);
  z-index: 6;
}

.lh-player [data-tip]:hover::after {
  opacity: 1;
}

.lh-player .lh-icon:disabled:hover::after {
  opacity: 0;
}

/* 3. Board */

.lh-player .lh-board {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  overflow: hidden;
  background: var(--table);
}

.lh-player .lh-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 24px;
  color: var(--muted);
  font-size: 18px;
  font-weight: 600;
  text-align: center;
}

/* 4. Words */

.lh-player .lh-word {
  position: absolute;
  left: var(--x, 0px);
  top: var(--y, 0px);
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--col, var(--w1));
  font-family: var(--font);
  font-size: var(--base);
  font-weight: 600;
  line-height: 1.15;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  visibility: hidden;
  transform: none;
  transform-origin: center center;
  transition: transform 200ms ease, opacity 200ms ease;
}

.lh-player .lh-word.is-set {
  visibility: visible;
}

.lh-player .lh-word:focus,
.lh-player .lh-word:focus-visible {
  box-shadow: none;
}

.lh-player .lh-word:hover {
  z-index: 2;
  transform: scale(1.05);
}

/* 5. Crossed-off words */

.lh-player .lh-word.is-off {
  opacity: 0.25;
  text-decoration: line-through;
  text-decoration-color: var(--muted);
  text-decoration-thickness: 0.12em;
}

/* 6. End card */

.lh-player .lh-end {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: transparent;
  opacity: 0;
  transition: opacity 280ms ease;
}

.lh-player .lh-end.is-on {
  opacity: 1;
}

.lh-player .lh-end[hidden] {
  display: none;
}

.lh-player .lh-end-card {
  width: min(340px, 100%);
  padding: 28px 28px 24px;
  border-radius: var(--radius);
  background: var(--white);
  box-shadow: var(--shadow-card);
  text-align: center;
}

.lh-player .lh-end-title,
.lh-player .lh-end-copy {
  margin: 0;
  max-width: none;
  font-family: var(--font);
  text-align: center;
}

.lh-player .lh-end-title {
  color: var(--ink);
  font-size: clamp(28px, 5vw, 36px);
  font-weight: 900;
  line-height: 1.1;
}

.lh-player .lh-end-copy {
  margin-top: 10px;
  color: var(--muted);
  font-size: 18px;
  font-weight: 600;
  line-height: 1.3;
}

.lh-player .pill-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 54px;
  min-height: 54px;
  margin-top: 22px;
  padding: 0 36px;
  border-radius: var(--radius-pill);
  background: var(--blue);
  color: var(--white);
  font-family: var(--font);
  font-size: 18px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
  box-shadow: 0 4px 0 var(--blue-edge);
}

.lh-player .pill-btn:hover {
  background: var(--blue);
  color: var(--white);
  box-shadow: 0 4px 0 var(--blue-edge);
}

.lh-player .pill-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--blue-edge);
}

.lh-player .pill-btn:focus-visible {
  box-shadow: 0 4px 0 var(--blue-edge), 0 0 0 3px var(--focus);
}

/* 7. Full screen */

.lh-player:fullscreen,
.lh-player:-webkit-full-screen {
  width: 100%;
  height: 100%;
  background: var(--table);
}

.lh-player:fullscreen .lh-bar,
.lh-player:-webkit-full-screen .lh-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  transform: translateY(-100%);
  transition: transform 200ms ease;
}

.lh-player:fullscreen.is-bar-on .lh-bar,
.lh-player:-webkit-full-screen.is-bar-on .lh-bar {
  transform: translateY(0);
}

.lh-player:fullscreen .lh-board,
.lh-player:-webkit-full-screen .lh-board {
  flex: 1 1 auto;
  height: 100%;
}

/* 8. Phones */

@media (max-width: 480px) {
  .lh-player .lh-title {
    display: none;
  }

  .lh-player .lh-home,
  .lh-player .lh-icon,
  .lh-player .lh-type {
    width: 40px;
    height: 40px;
  }
}

/* 9. Reduced motion */

@media (prefers-reduced-motion: reduce) {
  .lh-player .lh-word,
  .lh-player .lh-end,
  .lh-player:fullscreen .lh-bar,
  .lh-player:-webkit-full-screen .lh-bar {
    transition: none;
  }

  .lh-player .lh-word:hover {
    transform: none;
  }

  .lh-player .pill-btn:active {
    transform: none;
  }
}
