.rll-root {
  --rll-main: #1e3a5f;
  --rll-main-dark: #0f1e3a;
  --rll-accent: #d4af37;
  --rll-accent-light: #f4cf5f;
  --rll-text: #2c3e50;
  --rll-muted: #6f7f8c;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  min-height: 560px;
  color: var(--rll-text);
  font-family: system-ui, -apple-system, "Segoe UI", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
  line-height: 1.4;
  isolation: isolate;
}

.rll-root:fullscreen { height: 100vh; height: 100dvh; background: #eaf6ff; }
body.admin-bar .rll-root { height: calc(100vh - 32px); height: calc(100dvh - 32px); }
.rll-root, .rll-root * { box-sizing: border-box; }
.rll-root button, .rll-root select { font: inherit; }

.rll-app {
  position: relative;
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: linear-gradient(135deg, #0ea5e9, #6366f1 65%, #8b5cf6);
  border-radius: 18px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .16);
}

.rll-header {
  height: 66px;
  flex: 0 0 66px;
  padding: 9px 18px;
  display: grid;
  grid-template-columns: minmax(150px, 1fr) auto minmax(150px, 1fr);
  align-items: center;
  gap: 12px;
  color: #fff;
  background: var(--rll-main);
  border-top: 3px solid var(--rll-accent);
  border-bottom: 3px solid var(--rll-accent);
  box-shadow: 0 2px 10px rgba(0, 0, 0, .18);
  z-index: 30;
}

.rll-title { margin: 0; font-size: clamp(16px, 1.8vw, 22px); font-weight: 900; white-space: nowrap; }
.rll-mode-tabs {
  padding: 3px;
  display: flex;
  gap: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .13);
  overflow-x: auto;
  scrollbar-width: none;
}
.rll-mode-tabs::-webkit-scrollbar { display: none; }
.rll-mode-tab {
  min-height: 38px;
  min-width: 104px;
  padding: 7px 15px;
  border: 0;
  border-radius: 999px;
  color: #fff !important;
  -webkit-text-fill-color: #fff;
  background: transparent !important;
  font-weight: 900;
  white-space: nowrap;
  cursor: pointer;
}
.rll-mode-tab[aria-selected="true"] {
  color: var(--rll-main-dark) !important;
  -webkit-text-fill-color: var(--rll-main-dark);
  background: var(--rll-accent) !important;
}
.rll-fullscreen {
  justify-self: end;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: #fff !important;
  -webkit-text-fill-color: #fff;
  background: rgba(255, 255, 255, .14) !important;
  font-size: 24px;
  font-weight: 900;
  cursor: pointer;
}

.rll-workspace { flex: 1; min-height: 0; padding: 14px 88px 18px 14px; }
.rll-card {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  background: #fff;
  border-top: 4px solid var(--rll-accent);
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
}
.rll-canvas { display: block; width: 100%; height: 100%; touch-action: none; }

.rll-view-switch {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  padding: 4px;
  display: flex;
  gap: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .92);
  box-shadow: 0 4px 16px rgba(15, 30, 58, .18);
  z-index: 12;
}
.rll-view-button {
  min-height: 34px;
  padding: 5px 12px;
  border: 0;
  border-radius: 999px;
  color: #1e3a5f !important;
  -webkit-text-fill-color: #1e3a5f;
  background: transparent !important;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
  cursor: pointer;
}
.rll-view-button[aria-pressed="true"] {
  color: #0f1e3a !important;
  -webkit-text-fill-color: #0f1e3a;
  background: var(--rll-accent) !important;
}
.rll-mode-caption {
  position: absolute;
  left: 14px;
  bottom: 12px;
  max-width: min(70%, 620px);
  padding: 7px 12px;
  border-radius: 12px;
  color: #173955;
  background: rgba(255, 255, 255, .92);
  box-shadow: 0 3px 14px rgba(15, 30, 58, .16);
  font-size: 13px;
  font-weight: 900;
  pointer-events: none;
  z-index: 10;
}

.rll-loading, .rll-message {
  position: absolute;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  max-width: min(88%, 620px);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-radius: 14px;
  color: var(--rll-main-dark);
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 6px 24px rgba(15, 30, 58, .2);
  text-align: center;
  font-weight: 900;
  z-index: 20;
}
.rll-loading[hidden], .rll-message[hidden] { display: none; }
.rll-spinner { width: 24px; height: 24px; border: 4px solid #d9e6ef; border-top-color: var(--rll-main); border-radius: 50%; animation: rll-spin .8s linear infinite; }
.rll-message--fatal { border: 3px solid #c45555; color: #7f2424; }

.rll-toolbar {
  position: absolute;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 11px;
  pointer-events: none;
  z-index: 100;
}
.rll-tool {
  width: 58px;
  height: 58px;
  padding: 4px;
  border: 0;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--rll-main) !important;
  -webkit-text-fill-color: var(--rll-main);
  background: #fff !important;
  box-shadow: 0 5px 17px rgba(0, 0, 0, .25);
  line-height: 1;
  pointer-events: auto;
  cursor: pointer;
}
.rll-tool--add, .rll-tool--rain { color: var(--rll-main-dark) !important; -webkit-text-fill-color: var(--rll-main-dark); background: var(--rll-accent) !important; }
.rll-tool--rain.is-active { background: #45b9db !important; }
.rll-tool--reset { color: #a94242 !important; -webkit-text-fill-color: #a94242; }
.rll-tool-icon { font-size: 23px; font-weight: 900; line-height: 1; }
.rll-tool-label { margin-top: 3px; font-size: 9px; font-weight: 900; white-space: nowrap; }
.rll-tool:hover { transform: translateY(-2px); box-shadow: 0 7px 20px rgba(0, 0, 0, .3); }

.rll-settings-backdrop {
  position: absolute;
  inset: 66px 0 0;
  padding: 14px 86px 14px 14px;
  display: flex;
  justify-content: flex-end;
  align-items: flex-start;
  background: rgba(15, 30, 58, .22);
  backdrop-filter: blur(2px);
  z-index: 50;
}
.rll-settings-backdrop[hidden] { display: none; }
.rll-settings-panel {
  width: min(370px, 100%);
  max-height: 100%;
  padding: 15px;
  overflow: auto;
  border-top: 4px solid var(--rll-accent);
  border-radius: 16px;
  color: #263b4d;
  background: #fff;
  box-shadow: 0 10px 30px rgba(15, 30, 58, .26);
}
.rll-settings-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.rll-settings-title { margin: 0; color: var(--rll-main) !important; -webkit-text-fill-color: var(--rll-main); font-size: 18px; font-weight: 900; }
.rll-settings-close {
  width: 38px;
  height: 38px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: var(--rll-main) !important;
  -webkit-text-fill-color: var(--rll-main);
  background: #edf5fa !important;
  font-size: 24px;
  font-weight: 900;
}
.rll-settings-heading { margin: 14px 0 6px; color: var(--rll-main) !important; -webkit-text-fill-color: var(--rll-main); font-size: 13px; font-weight: 900; }
.rll-speed-picker { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 5px; border-radius: 12px; background: #edf5fa; }
.rll-speed-button {
  min-height: 42px;
  border: 2px solid #c9dce8 !important;
  border-radius: 10px;
  color: #1e3a5f !important;
  -webkit-text-fill-color: #1e3a5f;
  background: #fff !important;
  font-weight: 900;
}
.rll-speed-button[aria-pressed="true"] { border-color: var(--rll-accent) !important; color: var(--rll-main-dark) !important; -webkit-text-fill-color: var(--rll-main-dark); background: var(--rll-accent) !important; }
.rll-legend { padding: 10px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; border-radius: 12px; color: #263b4d; background: #edf5fa; font-size: 12px; font-weight: 800; }
.rll-legend-item { display: flex; align-items: center; gap: 7px; color: #263b4d !important; -webkit-text-fill-color: #263b4d; }
.rll-swatch { display: inline-block; border: 1px solid rgba(0,0,0,.2); border-radius: 50%; flex: 0 0 auto; }
.rll-swatch--gravel { width: 16px; height: 16px; background: #716354; }
.rll-swatch--pebble { width: 13px; height: 13px; background: #a28c73; }
.rll-swatch--sand { width: 10px; height: 10px; background: #d0a052; }
.rll-swatch--fine { width: 8px; height: 8px; background: #dcc58e; }
.rll-note { margin: 9px 0 0; padding: 8px 10px; border-radius: 10px; color: #355064; background: #fff7d8; font-size: 11px; font-weight: 700; }
.rll-dev { margin-top: 12px; padding: 9px; border-radius: 10px; color: #eaf7ff; background: #253a4c; font: 11px/1.45 ui-monospace, SFMono-Regular, Consolas, monospace; white-space: pre-wrap; }
.rll-dev[hidden] { display: none; }

.rll-root button:focus-visible { outline: 4px solid var(--rll-accent-light); outline-offset: 2px; }
.rll-noscript { margin: 0; padding: 18px; color: #7f2424; background: #fff; font-weight: 900; }

@keyframes rll-spin { to { transform: rotate(360deg); } }

@media (max-width: 900px) {
  .rll-header { grid-template-columns: auto 1fr auto; padding-inline: 10px; }
  .rll-title { font-size: 15px; }
  .rll-mode-tab { min-width: 88px; padding-inline: 10px; font-size: 13px; }
  .rll-workspace { padding: 10px 72px 12px 10px; }
  .rll-toolbar { right: 9px; bottom: 11px; gap: 8px; }
  .rll-tool { width: 52px; height: 52px; }
  .rll-settings-backdrop { padding: 10px 68px 10px 10px; }
}

@media (max-width: 640px) {
  .rll-root { min-height: 520px; }
  .rll-header { height: 58px; flex-basis: 58px; grid-template-columns: minmax(72px, auto) 1fr 38px; gap: 6px; padding: 7px 8px; }
  .rll-title { max-width: 82px; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
  .rll-mode-tabs { justify-content: flex-start; }
  .rll-mode-tab { min-width: 78px; min-height: 34px; padding: 5px 8px; font-size: 12px; }
  .rll-fullscreen { width: 38px; height: 38px; }
  .rll-view-switch { top: 7px; }
  .rll-view-button { min-height: 30px; padding: 4px 8px; font-size: 10px; }
  .rll-mode-caption { left: 8px; bottom: 7px; padding: 5px 8px; font-size: 10px; }
  .rll-settings-backdrop { inset: 58px 0 0; align-items: center; }
}

@media (max-width: 782px) {
  body.admin-bar .rll-root { height: calc(100vh - 46px); height: calc(100dvh - 46px); }
}

@media (max-width: 520px) and (orientation: portrait) {
  .rll-workspace { padding-right: 64px; }
  .rll-tool { width: 48px; height: 48px; }
  .rll-tool-icon { font-size: 20px; }
  .rll-tool-label { font-size: 8px; }
  .rll-settings-backdrop { padding-right: 62px; }
  .rll-legend { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .rll-root * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

