* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
}

#sketch-frame {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: auto;
  border: none;
}

/* ── Sketch label overlay ── */

#sketch-label {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  text-align: center;
  padding: 0 max(16px, 6vw);
  pointer-events: none;
  z-index: 50;
}

.label-japanese {
  font-family: serif;
  font-size: clamp(16px, 9vmin, 80px);
  color: rgba(240, 240, 235, 0.82);
  margin-bottom: 0.4em;
}

.label-desc {
  font-family: system-ui, sans-serif;
  font-size: clamp(12px, 3.5vmin, 32px);
  color: rgba(240, 240, 235, 0.7);
}

body.light-bg .label-japanese {
  color: rgba(40, 20, 30, 0.82);
}

body.light-bg .label-desc {
  color: rgba(40, 20, 30, 0.7);
}

/* ── Random button (top-left) ── */

#random-overlay {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 100;
}

#random-btn {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: background 0.2s, color 0.2s, border-color 0.2s;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

#random-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

body.light-bg #random-btn {
  background: rgba(0, 0, 0, 0.08);
  border-color: rgba(0, 0, 0, 0.15);
  color: rgba(0, 0, 0, 0.6);
}

body.light-bg #random-btn:hover {
  background: rgba(0, 0, 0, 0.15);
}

/* ── Search backdrop (captures outside taps) ── */

#search-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 99;
}

#search-backdrop.active {
  display: block;
}

/* ── Search (top-right) ── */

#search-overlay {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

/* Expandable pill — provides all visual styling for the search button area */
#search-expandable {
  display: flex;
  align-items: center;
  width: 40px;
  height: 40px;
  border-radius: 20px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: width 0.3s ease, background 0.2s, border-color 0.2s;
}

#search-expandable.open {
  width: min(300px, calc(100vw - 32px));
  background: rgba(0, 0, 0, 0.5);
  border-color: rgba(255, 255, 255, 0.25);
}

#search-toggle {
  background: transparent;
  border: none;
  width: 40px;
  min-width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.7);
  outline: none;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.2s;
}

#search-input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  color: #eee;
  font-size: 15px;
  font-family: system-ui, sans-serif;
  padding: 0 12px 0 0;
  outline: none;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
}

#search-expandable.open #search-input {
  opacity: 1;
  pointer-events: auto;
}

#search-input::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

/* Light theme */
body.light-bg #search-expandable {
  background: rgba(0, 0, 0, 0.08);
  border-color: rgba(0, 0, 0, 0.15);
}

body.light-bg #search-expandable.open {
  background: rgba(255, 255, 255, 0.65);
  border-color: rgba(0, 0, 0, 0.15);
}

body.light-bg #search-toggle {
  color: rgba(0, 0, 0, 0.6);
}

body.light-bg #search-input {
  color: #222;
}

body.light-bg #search-input::placeholder {
  color: rgba(0, 0, 0, 0.35);
}

/* ── Search results ── */

#search-results {
  list-style: none;
  margin-top: 8px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  overflow: hidden;
  max-height: 300px;
  overflow-y: auto;
  width: min(300px, calc(100vw - 32px));
  transition: background 0.2s, border-color 0.2s;
}

body.light-bg #search-results {
  background: rgba(255, 255, 255, 0.7);
  border-color: rgba(0, 0, 0, 0.12);
}

#search-results:empty {
  display: none;
}

#search-results li {
  padding: 10px 14px;
  cursor: pointer;
  color: #ddd;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-family: system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

#search-results li:last-child {
  border-bottom: none;
}

#search-results li:hover,
#search-results li.active {
  background: rgba(255, 255, 255, 0.1);
}

#search-results li .japanese {
  font-size: 18px;
  margin-bottom: 2px;
}

#search-results li .english {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
}

body.light-bg #search-results li {
  color: #222;
  border-bottom-color: rgba(0, 0, 0, 0.08);
}

body.light-bg #search-results li:hover,
body.light-bg #search-results li.active {
  background: rgba(0, 0, 0, 0.06);
}

body.light-bg #search-results li .english {
  color: rgba(0, 0, 0, 0.45);
}
